Python Azure上载的文件内容类型已更改为application/octet-stream [英] Python azure uploaded file content type changed to application/octet-stream

查看:71
本文介绍了Python Azure上载的文件内容类型已更改为application/octet-stream的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用python Azure sdk.文件上传后,其内容类型更改为application/octet-stream.

I am using python Azure sdk. When the file uploaded its content type changed to application/octet-stream.

我想为PNG图片设置其默认内容类型,例如 image/png .

I want to set its default content type like image/png for PNG image.

我正在使用以下方法上传文件 put_block_blob_from_path()

I am using following method for upload the file put_block_blob_from_path()

有什么办法可以保留默认的内容类型?谢谢

is there any way to retain default content type? Thanks

推荐答案

您可以像这样显式设置content-type属性:

You can explicitly set the content-type property like this:

from azure.storage.blob import ContentSettings

block_blob_service.create_blob_from_path(
    'mycontainer',
    'myblockblob',
    'mypngimage.png',
    content_settings=ContentSettings(content_type='image/png')
)

来源: https://docs.microsoft.com/zh-CN/azure/storage/blobs/storage-python-how-to-use-blob-storage

这篇关于Python Azure上载的文件内容类型已更改为application/octet-stream的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆