step-up-labs / firebase-storage-dotnet

C# library for Firebase Storage
MIT License
140 stars 35 forks source link

Added support for prefix and file list. #35

Closed nmoschkin closed 2 years ago

nmoschkin commented 3 years ago

The functions you want are two functions in FirebaseStorage: ListRootPrefixes, and ListAllFiles Each FirebaseStorageReference has the functions ListPrefixes and ListFiles.

I documented the functions in code.

One other thing. Google Cloud Storage API (upon which Firebase calls are based) has a limit of 1000 items per return, and if there's more items you get a nextPageToken. Call the ListPrefixes and ListFiles with the pageToken returned in the last call to get the next page of results. So to get an entire list, keep fetching until the nextPageToken is either null or the same as the last token or the total number of results is less than the maximum allowed number of results. I have documented this, somewhat, in code, as well. If you attempt to pass a maxResults outside the range of 1-1000 you will get an ArgumentOutOfRangeException that I have thrown.

bpass1 = await Storage.ListRootPrefixes();

foreach (var prefix in bpass1.Prefixes)
{
    bpass2 = await Storage.Child(prefix)
         .Child("models")
         .Child("model-export")
         .Child("icn")
         .ListFiles(); 

    outBucket.AddRange(bpass2.Items);
}
stale[bot] commented 2 years ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

stale[bot] commented 2 years ago

Closing the issue due to inactivity. Feel free to re-open