繁体   English   中英

Azure.Storage.Blobs 文件夹结构

[英]Azure.Storage.Blobs Folder Structure

几年来,我们已经使用折旧的 WindowsAzure.Storage nuget 实现了 Azure 的现有实现。

我们正在将 nuget 升级到新的 Azure.Storage.Blobs nuget。

作为原始实现的一部分,blob 将存储在容器内的文件夹结构中:容器/年/月/:

  • 测试/2021/01/test.pdf
  • 测试/2020/12/test.pdf

要求是这应该继续前进,但如果可能的话,我不能再锻炼了。

有没有人设法让它工作?

您可以通过代码简单地创建它:

using Azure.Storage;
using Azure.Storage.Blobs;
using Azure.Storage.Blobs.Models;

// Get a connection string to our Azure Storage account.  You can
// obtain your connection string from the Azure Portal (click
// Access Keys under Settings in the Portal Storage account blade)
// or using the Azure CLI with:
//
//     az storage account show-connection-string --name <account_name> --resource-group <resource_group>
//
// And you can provide the connection string to your application
// using an environment variable.
string connectionString = "<connection_string>";

// Get a reference to a container named "sample-container" and then create it
BlobContainerClient container = new BlobContainerClient(connectionString, "sample-container");
container.Create();

// Get a reference to a blob named "sample-file" in a container named "sample-container"
BlobClient blob = container.GetBlobClient("sample-folder/sample-file");

// Open a file and upload it's data
using (FileStream file = File.OpenRead("local-file.jpg"))
{
    blob.Upload(file);
}

查看来自 PG 的有关此 nuget 的文档

在 Azure 的 Blob 存储中,您没有所谓的文件夹结构 都是虚拟的。 如果您在代码的 blob 引用部分中使用您希望它的完整路径(在您的情况下为年/月)指定 blob 的名称,则可以保留与上传 blob 相同的逻辑。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM