【问题标题】:Content Type being overwritten when sending to Azure Blob container发送到 Azure Blob 容器时内容类型被覆盖
【发布时间】:2021-10-05 01:12:37
【问题描述】:

因此,在我的代码中,我已将内容类型设置为被上传的任何内容替换,但 Azure 一直使用默认的 application/octet-stream 覆盖它。我可以在网络选项卡中看到内容类型是 image/png 并且在通过 http 的 axios 请求中,在配置标头中它已设置为内容类型,但是当进入容器查看文件时,它是应用程序/八位字节流。

请注意,我使用的是 npm 包 vue-azure-blob-upload

 http.put(uri, requestData,
        {
          headers: {
            'x-ms-blob-type': 'BlockBlob',
            'Content-Type': state.file.type,
            'x-ms-version': '2020-10-02',
            'x-ms-date': new Date(),
          },
          transformRequest: [],
        }).then(function (response) {
        $log(response);
         }

在 http.js 中:

init() {
    axios.defaults.headers.put['Content-Type'] = 'image/png';
},

【问题讨论】:

  • 请尝试将请求中的Content-Type 标头更改为x-ms-content-type
  • @GauravMantri 我试过它不起作用,但通过添加 blob 使其变为x-ms-blob-content-type 它起作用了,所以感谢您朝着正确的方向推动!
  • 对不起...我的错!是的,它是x-ms-blob-content-type

标签: azure npm azure-blob-storage


【解决方案1】:

谢谢Gaurav Mantri。添加您的评论部分建议以回答以帮助其他社区成员。

将请求中的content-type标头从state.file.type更改为x-ms-blob-content-type

【讨论】:

    猜你喜欢
    • 2018-06-27
    • 1970-01-01
    • 2019-02-06
    • 2020-05-02
    • 2021-09-17
    • 2013-02-21
    • 2013-11-24
    • 1970-01-01
    • 2022-01-08
    相关资源
    最近更新 更多