无法设置Azure Blob的内容类型

时间:2018-11-05 15:28:40

标签: typescript azure azure-blob-storage

我将数据存储在Azure上,并将 Content-Type 放在标题字段中,同时上传如下代码:

const headers: any = {
    'Content-Range': contentRange,
    'Content-Type': "image/svg+xml",
};

const responseData: any = await putChunk(url, chunks[currentChunkIndex].blob, headers);

以下是我创建blob并将其推入块数组的方法:

var blob = new Blob([file.slice(start, end)], { type: 'image/svg+xml' });
const chunk = new FileChunk(blob, file.size, start, end, file.name);
chunks.push(chunk);

下面是putChunk()函数,该函数仅发送一个PUT请求:

async function putChunk(url: string, data: any, headers: any): Promise<any> {
            const options: any = {
                method: 'PUT',
                headers: headers,
                body: 
            return await fetch(url, options);
        }

无论将内容类型设置为什么,blob和chunk都始终将其重置为application / octet-stream。我想念什么?

1 个答案:

答案 0 :(得分:2)

  

无论内容类型设置为什么,它总是重置为   应用程序/八位位组流。我想念什么?

问题是您要设置块的内容类型,而不是blob的内容类型。

要设置Blob的内容类型,您需要在您的Put Block List请求中包含x-ms-blob-content-type标头并将值设置为image/svg+xml,然后您会看到正确的内容斑点的类型。

相关问题