2
votes

I am storing the data on Azure and putting Content-Type in the headers field while uploading a chunk like so:

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

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

Following is the way I am creating blobs and pushing them into a a chunk array:

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);

Following is the putChunk() function that simply sends a PUT request:

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

No matter what the content-type is set to, of blobs and chunks likewise, it always resets to application/octet-stream. What am I missing?

1

1 Answers

3
votes

No matter what the content-type is set to, it always resets to application/octet-stream. What am I missing?

The issue is that you're setting the content type of the chunk and not that of the blob.

In order to set the content type of the blob, you would need to include x-ms-blob-content-type header and set the value as image/svg+xml in your Put Block List request and then you will see proper content type of the blob.