Search code examples
azureazcopy

AZCopy: Set the file Content-Type


We are trying to use AZCopy in our deployment script to upload some assets directly into our storage which is exposed via a CDN on Azure.

When we upload the files, the Content-Type is application/octet-stream but we would need to be able to specify by example text/javascript

Is there a way to achieve this? We don't bother having to call AZCopy several times for each file types.


Solution

  • The latest version of AzCopy (v3.1.0 and v4.1.0-preview) has included the support for setting content type, please download and find more details at http://aka.ms/azcopy.

    To be more specific, you can set the content type via the option /SetContentType:[content-type].

    AzCopy /Source:D:\test\ /Dest:https://myaccount.blob.core.windows.net/myContainer/ /DestKey:key /Pattern:ab /SetContentType

    AzCopy /Source:D:\test\ /Dest:https://myaccount.blob.core.windows.net/myContainer/ /DestKey:key /Pattern:ab /SetContentType:video/mp4

    If "Content-Type" is not specified at the /SetContentType option, AzCopy will set each blob’s content type according to its file extension. To set the same content type for all the blobs, you must explicitly specify a value for “Content-Type", for example, /SetContentType:video/mp4. Note that this option is only applicable when uploading blobs to the storage end points.