NodeJS '@azure/storage-blob': How do set Blob Service Properties when uploading a file

728 Views Asked by At

From this document, there is no example to set Blob Service Properties.

Below is my Sample Code:

let containerClient = blobServiceClient.getContainerClient(CONTAINERNAME),
    blockBlobClient = containerClient.getBlockBlobClient(BLOBNAME);

await blockBlobClient.uploadFile(FILEPATH);

Please advise how I can upload a file with setting contentDisposition and contentType in properties of blockBlob.

1

There are 1 best solutions below

2
On BEST ANSWER

Please try this way:

    const blobOptions = { blobHTTPHeaders: { blobContentType: 'image/jpeg', blobContentDisposition: "attachment; filename=package.jpg" } };
    const uploadBlobResponse =await blockBlobClient.uploadFile(filePath,blobOptions);

If there are other questions, please let me know!