I am trying to upload Blob
from Stream
with .Net 12 SDK, setting ContentType
and overwrite
property to true same time.
There are few overloads of BlobClient.Upload
method. But none of them accepts both parameters.
As an alternative I can set ContentType
in the second step, but would prefer to do in one.
BlobHttpHeaders blobHttpHeaders = new BlobHttpHeaders();
blobHttpHeaders.ContentType = "text/xml";
blobClient.SetHttpHeaders(blobHttpHeaders);
Is that possible in one run?
CodePudding user response:
The efficient way to do the same with a single method is as follows,
await blobClient.UploadAsync(ms, new BlobHttpHeaders{ ContentType = "text/xml"});
OR
using Stream stream = file.ToStream();
var result = await blobClient.UploadAsync(stream, new BlobHttpHeaders { ContentType = "text/xml" });