AZCopy: specify the Content-Type file

We are trying to use AZCopy in our deployment script to load some assets directly into our repository, which opens through the CDN on Lazur.

When we upload the files, Content-Type application/octet-stream , but we will need to provide an example text/javascript

Is there any way to achieve this? We do not need to call AZCopy several times for each type of file.

+6
source share
2 answers

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

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

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 the "Content-Type" is not specified in the / SetContentType parameter, AzCopy will set each type of blob content according to the file extension. To specify the same content type for all blocks, you must explicitly specify a value for "Content-Type", for example, / SetContentType: video / mp4. Please note that this option is applicable only when loading the drop to the storage endpoints.

+13
source

Having looked at the options available in AZCopy, I do not think that this is possible. You will need to write some code to set the type of blob content after loading it.

What you can do is select a list of blocks in the desired container. The Blob list will provide you with the current content type of each blob. Then you will need to iterate over this list, find out the content type from the file extension ( Get the MIME type with the file name extension ), and then set the blob properties with the updated content type.

+1
source

Source: https://habr.com/ru/post/957918/


All Articles