Search code examples
azureazure-storageazure-blob-storage

Copy css file from one subdirectory to another one in CONTAINER BLOB


Scenario:

I copy .css file from one subdirectory to another in Azure Storage Container. It is done from C# code level in my application. This is css style file for my website. Unfortunately I received error in my browser console during loading page:

Error

Resource interpreted as Stylesheet but transferred with MIME type application/octet-stream: 
"SOME_PATH/template/css/styles.css?d=00000000-0000-0000-0000-000000000000".

Knowledge:

I know that it is why my file is sended as octet-stream instead of text/css. What can I do to say Azure to treat this file as text/css? AZURE BLOB

Edit: My code

    string newFileName = fileToCopy.Name;
    StorageFile newFile = cmsDirectory.GetStorageFileReference(newFileName);
    using (var stream = new MemoryStream())
    {
        fileToCopy.DownloadToStream(stream);
        stream.Seek(0, SeekOrigin.Begin);
        newFile.UploadFromStream(stream);
    }

where DownloadToStream and UploadToStream are methodes in my class:

CloudBlob.DownloadToStream(target);

and

CloudBlob.DownloadToStream(target);

CloudBlob is CloudBlockBlob type


Solution

  • You can set content type of blob via property ContentType

    look at: https://learn.microsoft.com/en-us/dotnet/api/microsoft.windowsazure.storage.blob.blobproperties.contenttype