我正在将一些旧的应用程序服务代码移植到Microsoft Azure中,需要一些帮助。
我从一个存储过程中提取了一些数据并创建了一个SpreadsheetLight文档(这是从旧代码引入的,因为我的用户希望保留这个过程中已经内置的大量格式)。这段代码运行良好,但我需要将文件直接写入我们的azure blob容器,而不需要先保存本地副本(因为此过程将在管道中运行)。使用我找到的一些示例代码作为指南,我能够通过本地保存并将其上传到blob存储来使其在调试中工作……但现在我需要找到一种方法,在上传之前删除本地保存的内容。
发布于 2021-09-14 20:53:56
实际上,我偶然发现了解决方案。
string connectionString = "YourConnectionString";
string containerName = "YourContainerName";
string strFileNameXLS = "YourOutputFile.xlsx";
BlobServiceClient blobServiceClient = new BlobServiceClient(connectionString);
BlobContainerClient blobContainerClient = blobServiceClient.GetBlobContainerClient(containerName);
BlobClient blobClient = blobContainerClient.GetBlobClient(strFileNameXLS);
SLDocument doc = YourSLDocument();
using (MemoryStream ms = new MemoryStream())
{
doc.SaveAs(ms);
ms.Position = 0;
await blobClient.UploadAsync(ms, true);
ms.Close();
}https://stackoverflow.com/questions/69183693
复制相似问题