0

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.

DaiKeung
  • 1,077
  • 1
  • 19
  • 38

1 Answers1

3

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!

Frank Borzage
  • 6,292
  • 1
  • 6
  • 19
  • May I know how to handle exception like there is outage of Azure service? e.g. there is errorHandler defined in serviceBus: `receiver.registerMessageHandler(onMessageHandler, onErrorHandler);` – DaiKeung Oct 23 '20 at 01:07
  • Hi, @DaiKeung. I don't know this problem very well, because there are many Azure services, maybe you can ask a question in stack overflow, but it's better to be specific to a certain service. In addition, the most common way to handle exceptions is to use `try...catch...`, you can refer to this [official document](https://learn.microsoft.com/en-us/azure/azure-functions/functions-bindings-error-pages). – Frank Borzage Oct 23 '20 at 01:36