Open devbeard opened 4 years ago
add to S170
Hi @devbeard , you can consider specifying --content-type
to configure MIME type when uploading. If there is other requirement, feel free to let me know.
Hi @devbeard , you can consider specifying
--content-type
to configure MIME type when uploading. If there is other requirement, feel free to let me know.
Hoping I didn’t misunderstand this, but this is only true for uploads and batch uploads if you upload a single file type. If you for example need to upload a folder of CDN content (Microsoft’s suggested architecture), you have .js files, images, static yaml files and so on. A single mime type is not going to help this scenario.
@devbeard Thanks for your detailed information! We will consider the feature you proposed and prioritize it after internal discussion.
will consider the implementation when migrating track 2.
If someone else comes across this thread, I managed to sort of get it working, but I don't think it is a perfect workaround, and I hope MSFT continues with a solution on their end as well @Juliehzl .
Workaround: By leveraging that I am root in my container that I deploy to the storage account from (build pipeline), I change the mimetypes in the system on the fly. I have a mimetype file in my CDN repository that I utilize to version control the mapping.
touch /etc/mime.types
cat ./my-mime-types | tee -a /etc/mime.types
az storage blob upload-batch --destination $STR_CONTAINER --source ./cdn --connection-string "$CDN_CSTR"
AzCli (and the mimetype python module, whos defaults are a bit dated) seems to have code for user folder lookup of a mimetype file, but I could only get the system replacement working. See these lines: https://github.com/python/cpython/blob/master/Lib/mimetypes.py#L42-L52
Example contents of my repo mimetype file:
font/ttf ttf
font/woff woff
font/woff2 woff2
image/x-icon ico
text/javascript js
application/xml xml
application/octet-stream map
I am also interested in this feature. I would love to be able to specify either a key/value pair as a parameter or a file path that contains a key/value pair.
I would also like to see a --mime-types
argument for batch-upload
. It seems like a very common use case.
I am using Azure CLI to batch-upload
all the built files for a web project within a Github Workflow.
Turns out you can modify the /etc/mime.types
in the container used by azure/CLI
before you call upload-batch
Thanks for the helpful workaround @devbeard
- name: Upload to Azure Blob Storage
uses: azure/CLI@v1
with:
inlineScript: |
cat ./my-mime-types | tee -a /etc/mime.types
az storage blob upload-batch -s dist -d my-container
Any new ideas/workarounds?
I ended up using AzCopy for this as it has MIME type detection done automatically
Is your feature request related to a problem? Please describe.
When using a storage account as a static file host and uploading a large set of files, it is really annoying when the content type is guessed wrong. Especially since these metadata seems impossible to update via
az
.Example: woff2 file should (since 2017) have content type
font/woff2
, but is uploaded asapplication/octet-stream
when usingaz storage blob upload-batch
.Describe the solution you'd like
The ability to provide the path to a custom mime-types file (hopefully with the same syntax as other mime.types files) or clear instructions (across OS) on how to configure . Especially how to configure the Docker image
mcr.microsoft.com/azure-cli
to work with custom mime-types.Example:
az storage blob upload-batch --source ./folder --destination static --connection-string <cstr> --mime-types ./my-mime-types.conf
Describe alternatives you've considered
Beyond programming my own bulk uploader, I don't have any suggestions for workarounds.
Additional context