且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何使用 .NET v12 SDK 上传具有指定 ContentType 的 Azure Blob 存储中的 Blob?

更新时间:2023-02-14 20:33:45

可以如下设置,

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

如评论中所述,使用单一方法执行相同操作的有效方法如下,

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