IFileProvider Azure 文件存储
IFileProvider Azure File storage
我正在考虑实现 IFileProvider
与 Azure 文件存储的接口。
我想在文档中找到的是,是否有一种方法可以将文件的整个路径发送到 Azure API,例如 rootDirectory/sub1/sub2/example.file
,或者实际上是否应该映射到某个采用路径和遍历文件存储上的目录结构?
只是想确保我没有遗漏任何东西并为已经存在的东西重新发明轮子。
[更新]
我正在使用 .NET 的 Azure 存储客户端。我不想安装任何东西。
我的意图是有几个 IFileProviders
,我可以根据 Environment
和其他条件进行切换。
因此,例如,如果我的环境是 Cloud
,那么我将使用 IFileProvider
通过 Azure 存储客户端使用 Azure 文件服务的实现。接下来,如果我有环境 MyServer
,那么我将使用服务器本地文件系统。第三个选项是具有该特定实现的环境 someOther
。
现在,对于所有这些,IFileProvider
以类似 root/sub1/sub2/sub3
的路径运行。对于 Azure 文件存储,有没有一种方法可以一次发送整个路径以获得 sub3
info/content,或者应该将路径分成单独的目录并为每个步骤获取 reference/content?
我希望问题解决了。
Now, for all of them, IFileProvider operates with path like ˙root/sub1/sub2/sub3. For Azure File Storage, is there a way to send the whole path at once to getsub3` info/content or should the path be broken into individual directories and get reference/content for each step?
要跨多个子目录访问特定的子目录,可以使用GetDirectoryReference
方法构造CloudFileDirectory
,如下:
var fileshare = storageAccount.CreateCloudFileClient().GetShareReference("myshare");
var rootDir = fileshare.GetRootDirectoryReference();
var dir = rootDir.GetDirectoryReference("2017-10-24/15/52");
var items=dir.ListFilesAndDirectories();
要访问子目录下的特定文件,您可以使用GetFileReference
方法来return CloudFile
实例,如下所示:
var file=rootDir.GetFileReference("2017-10-24/15/52/2017-10-13-2.png");
我正在考虑实现 IFileProvider
与 Azure 文件存储的接口。
我想在文档中找到的是,是否有一种方法可以将文件的整个路径发送到 Azure API,例如 rootDirectory/sub1/sub2/example.file
,或者实际上是否应该映射到某个采用路径和遍历文件存储上的目录结构?
只是想确保我没有遗漏任何东西并为已经存在的东西重新发明轮子。
[更新]
我正在使用 .NET 的 Azure 存储客户端。我不想安装任何东西。
我的意图是有几个 IFileProviders
,我可以根据 Environment
和其他条件进行切换。
因此,例如,如果我的环境是 Cloud
,那么我将使用 IFileProvider
通过 Azure 存储客户端使用 Azure 文件服务的实现。接下来,如果我有环境 MyServer
,那么我将使用服务器本地文件系统。第三个选项是具有该特定实现的环境 someOther
。
现在,对于所有这些,IFileProvider
以类似 root/sub1/sub2/sub3
的路径运行。对于 Azure 文件存储,有没有一种方法可以一次发送整个路径以获得 sub3
info/content,或者应该将路径分成单独的目录并为每个步骤获取 reference/content?
我希望问题解决了。
Now, for all of them, IFileProvider operates with path like ˙root/sub1/sub2/sub3. For Azure File Storage, is there a way to send the whole path at once to getsub3` info/content or should the path be broken into individual directories and get reference/content for each step?
要跨多个子目录访问特定的子目录,可以使用GetDirectoryReference
方法构造CloudFileDirectory
,如下:
var fileshare = storageAccount.CreateCloudFileClient().GetShareReference("myshare");
var rootDir = fileshare.GetRootDirectoryReference();
var dir = rootDir.GetDirectoryReference("2017-10-24/15/52");
var items=dir.ListFilesAndDirectories();
要访问子目录下的特定文件,您可以使用GetFileReference
方法来return CloudFile
实例,如下所示:
var file=rootDir.GetFileReference("2017-10-24/15/52/2017-10-13-2.png");