I am thinking about implementing IFileProvider
interface with Azure File Storage.
What i am trying to find in docs is if there is a way to send the whole path to the file to Azure API like rootDirectory/sub1/sub2/example.file
or should that actually be mapped to some recursion function that would take path and traverse directories structure on file storage?
just want to make sure i am not missing something and reinvent the wheel for something that already exists.
[UPDATE]
I'm using Azure Storage Client for .NET. I would not like to mount anything.
My intentention is to have several IFileProviders
which i could switch based on Environment
and other conditions.
So, for example, if my environment is Cloud
then i would use IFileProvider
implementation that uses Azure File Services through Azure Storage Client. Next, if i have environment MyServer
then i would use servers local file system. Third option would be environment someOther
with that particular implementation.
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 get sub3
info/content or should the path be broken into individual directories and get reference/content for each step?
I hope that clears the question.
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?
For access the specific subdirectory across multiple sub directories, you could use the GetDirectoryReference
method for constructing the CloudFileDirectory
as follows:
var fileshare = storageAccount.CreateCloudFileClient().GetShareReference("myshare");
var rootDir = fileshare.GetRootDirectoryReference();
var dir = rootDir.GetDirectoryReference("2017-10-24/15/52");
var items=dir.ListFilesAndDirectories();
For access the specific file under the subdirectory, you could use the GetFileReference
method to return the CloudFile
instance as follows:
var file=rootDir.GetFileReference("2017-10-24/15/52/2017-10-13-2.png");