How upload blob in Azure Blob Storage with specified ContentType with .NET v12 SDK?

后端 未结 2 418
忘掉有多难
忘掉有多难 2020-12-02 00:58

I just started the Quickstart with .NET v12 SDK https://docs.microsoft.com/da-dk/azure/storage/blobs/storage-quickstart-blobs-dotnet

But i cant seem to find out how

2条回答
  •  南方客
    南方客 (楼主)
    2020-12-02 01:27

    You can set it as follows,

     await blobClient.UploadAsync(stream, true, default);
     await blobClient.SetHttpHeadersAsync(new BlobHttpHeaders
     {
        ContentType = contentType
     });
    

    EDIT: As mentioned in the comment, the efficient way to do the same with a single method as follows,

    await blobClient.UploadAsync(ms, new BlobHttpHeaders{ ContentType = "text/plain"});
    

提交回复
热议问题