作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我查看了以下链接以将字符串上传到 azure blob。我的任务要求不允许我将字符串存储为文件。
Is there any way of writing file to Azure Blob Storage directly from C# application?
它在 WindowsAzure.Storage 中使用 CloudStorageAccount,根据 this link 已弃用。
我正在尝试使用 Azure.Storage.Blobs 库。然而,按照 this microsoft documentation 不再有 UploadString 方法
有什么建议吗?谢谢
最佳答案
您可以上传流,因此您可以将字符串的内容作为字节数组获取,创建内存流并上传。
BlobContainerClient container = new BlobContainerClient(connectionString, "myContainer");
container.Create();
BlobClient blob = container.GetBlobClient("myString");
var myStr = "Hello!"
var content = Encoding.UTF8.GetBytes(myStr);
using(var ms = new MemoryStream(content))
blob.Upload(ms);
关于c# - 将字符串上传到 Azure Blob,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/64546110/
我是一名优秀的程序员,十分优秀!