如果我有 _full_ 绝对 uri,如何获取对 Azure blob/file 的文件引用?
How to GetFileReference to an Azure blob/file if I have the _full_ absolute uri?
在我的数据库中,我拥有我们 azure 文件的完整绝对 Uri
。
例如
https://<snip>.file.core.windows.net/share1/Brand1/Export_2017-05-11-12-54.xml
https://<snip>.file.core.windows.net/share1/Brand1/asdfasdfasd.xml
https://<snip>.file.core.windows.net/share1/Brand2/PewPew%20-%20Sample-78206580-1dd8-4de2-9b92-002bdca861a5.xml
请注意:
- Azure 文件
Share
名称,例如share1
- 文件名中有一个或多个
/
。例如brand1/blah.xml
我正在尝试查看该文件是否存在,然后对其进行操作(例如下载它,等等)。
我需要先得到一个 File Reference
这个项目。我已经完成了设置 that 的所有仪式(SAS
,等等)。
这是我获取文件引用的方式:
var cloudFile = ShareRootDirectory.GetFileReference(fileName);
如果 fileName = "Brand1/Export_2017-05-11-12-54.xml
它会起作用(注意:那里没有 share
或 https://....
。)
否则会出错。
有没有什么办法,给定 azure 上文件的完整绝对 uri,我可以将 something 传递给我之前的设置 ShreRootDirectory
到get/check 文件?或者我需要换一种方式吗?
有什么技巧吗?
注意:
- 我有一个共享文件夹(用于文件)
- 文件名中有 /
,这给人一种文件夹的错觉。
这是我执行此操作的屏幕截图:
var tempCloudFile = new CloudFile(new Uri(fileName));
如果您有权访问存储凭据,则可以使用以下对 CloudFile
的覆盖来获取该文件的引用,然后对该文件执行操作。例如,我在下面获得了 CloudFile 的参考并检查它是否存在。
var cred = new StorageCredentials(accountName, accountKey);
var file = new CloudFile(new Uri("https://<snip>.file.core.windows.net/share1/Brand1/Export_2017-05-11-12-54.xml"), cred);
var exists = file.Exists();
在我的数据库中,我拥有我们 azure 文件的完整绝对 Uri
。
例如
https://<snip>.file.core.windows.net/share1/Brand1/Export_2017-05-11-12-54.xml
https://<snip>.file.core.windows.net/share1/Brand1/asdfasdfasd.xml
https://<snip>.file.core.windows.net/share1/Brand2/PewPew%20-%20Sample-78206580-1dd8-4de2-9b92-002bdca861a5.xml
请注意:
- Azure 文件
Share
名称,例如share1
- 文件名中有一个或多个
/
。例如brand1/blah.xml
我正在尝试查看该文件是否存在,然后对其进行操作(例如下载它,等等)。
我需要先得到一个 File Reference
这个项目。我已经完成了设置 that 的所有仪式(SAS
,等等)。
这是我获取文件引用的方式:
var cloudFile = ShareRootDirectory.GetFileReference(fileName);
如果 fileName = "Brand1/Export_2017-05-11-12-54.xml
它会起作用(注意:那里没有 share
或 https://....
。)
否则会出错。
有没有什么办法,给定 azure 上文件的完整绝对 uri,我可以将 something 传递给我之前的设置 ShreRootDirectory
到get/check 文件?或者我需要换一种方式吗?
有什么技巧吗?
注意:
- 我有一个共享文件夹(用于文件)
- 文件名中有 /
,这给人一种文件夹的错觉。
这是我执行此操作的屏幕截图:
var tempCloudFile = new CloudFile(new Uri(fileName));
如果您有权访问存储凭据,则可以使用以下对 CloudFile
的覆盖来获取该文件的引用,然后对该文件执行操作。例如,我在下面获得了 CloudFile 的参考并检查它是否存在。
var cred = new StorageCredentials(accountName, accountKey);
var file = new CloudFile(new Uri("https://<snip>.file.core.windows.net/share1/Brand1/Export_2017-05-11-12-54.xml"), cred);
var exists = file.Exists();