10.0.1-Preview
Windows & Linux
azcopy /SetContentType
ContentType detection makes use of the built-in http.DetectContentType in Go, however this does not correctly identify the content type of JSON files (as well as JavaScript files and SVG images). This is particularly problematic when uploading material to be used in a static website. See the following for detail of the problem caused and some work-arounds:
https://liftcodeplay.com/2017/11/28/how-to-fix-azure-storage-blob-content-types/
Use azcopy on a test.json file and inspect the content type, set as application/octet-stream which then prevents the JSON from loading correctly in a client browser. Copy the same file using the Azure Storage Explorer and the correct content type is detected.
Two approaches to mitigation;
AzCopy\AzCopy.exe" /Source:"" /Dest:"https://my.blob.core.windows.net/$web" /Pattern:"*.json" /S /Y /SetContentType:"application/json" /Z /VA better solution for customers would be to have some additional extra file extension based ContentType heuristics in AzCopy for common miss-detected types. The JSON mime-type issue is particularly problematic and hard for end-users to debug as a content type problem.
Hi @martinwoodward, thanks for reaching out!
The sample command in your description is actually for AzCopy V8; we've dramatically changed the command-line interface in V10.
Nevertheless, I tried uploading a json and js file using AzCopyV10, and got "text/plain" for both content-types. I've added an item to our backlog to improve the content type detection. Thank you very much for the suggestion!
@zezha-msft This enhancement would be greatly appreciated!
Hi @eddiedozier, we are actively working on this enhancement. Thanks!
This is fixed.
which version of azcopy fixed the problem?
AzCopy 10.2.1 does not properly set/detect the content-type for *.json files for me.
as it seems, 10.2.x has a small list of content-types baked in, that works for *.js, *.css, *.html and maybe even some more. If you need *.json support you may add it via /etc/mime.types with a line like this:
application/json json
Most helpful comment
Hi @martinwoodward, thanks for reaching out!
The sample command in your description is actually for AzCopy V8; we've dramatically changed the command-line interface in V10.
Nevertheless, I tried uploading a json and js file using AzCopyV10, and got "text/plain" for both content-types. I've added an item to our backlog to improve the content type detection. Thank you very much for the suggestion!