Closed Go2sites closed 2 years ago
No, that isn't supported currently
I wrote an extension for this to list files.
If anyone wants it.... let me know.
(also wrote an extension to download files, too, with or without the token, as long as you're logged in)
I wrote an extension for this to list files.
If anyone wants it.... let me know.
(also wrote an extension to download files, too, with or without the token, as long as you're logged in)
Hi @nmoschkin
I would love to have it, could you pastebin it? Thanks <3
I wrote an extension for this to list files. If anyone wants it.... let me know. (also wrote an extension to download files, too, with or without the token, as long as you're logged in)
Hi @nmoschkin
I would love to have it, could you pastebin it? Thanks <3
Well ... it's sort of a work-in-progress... I haven't actually formalized it to work as the JavaScript library or as this FirebaseStorage component works ...
But I can paste what I have... Let me get back to you in a couple of days.
I wrote an extension for this to list files. If anyone wants it.... let me know. (also wrote an extension to download files, too, with or without the token, as long as you're logged in)
Hi @nmoschkin I would love to have it, could you pastebin it? Thanks <3
Well ... it's sort of a work-in-progress... I haven't actually formalized it to work as the JavaScript library or as this FirebaseStorage component works ...
But I can paste what I have... Let me get back to you in a couple of days.
Thank you ππ»
@maned3v
And I finally got around to putting it all together!
I forked the project and committed my changes... see below for an example of the code in use.
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.
All that being said, have fun, and enjoy!
I'm going to create a pull request, but I have no idea if it will be accepted or if this is the final form they want, but I'm going to attempt to, anyway. They haven't worked on this, in a while... so I hope this helps some people.
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);
}
Thank you @nmoschkin awesome!
@nmoschkin Seems all the list functions are not working anymore (ListFiles, ListPrefixes, ListRootPrefixes). It throws an exception "Response status code does not indicate success: 404 (Not Found)." I think the link was changed, please help to check. Thank you very much!
Ah yes. There seems to have been a small change to the way they recognized projects.
You may pull the latest changes. Itβs fixed (or should be fixed)
From: hoangatpaygate @.> Sent: Sunday, April 11, 2021 4:43 AM To: step-up-labs/firebase-storage-dotnet @.> Cc: Nathaniel Moschkin @.>; Mention @.> Subject: Re: [step-up-labs/firebase-storage-dotnet] List all files (#32)
@nmoschkinhttps://github.com/nmoschkin Seems all the list functions are not working anymore (ListFiles, ListPrefixes, ListRootPrefixes). It throws an exception "Response status code does not indicate success: 404 (Not Found)." I think the link was changed, please help to check. Thank you very much!
β You are receiving this because you were mentioned. Reply to this email directly, view it on GitHubhttps://github.com/step-up-labs/firebase-storage-dotnet/issues/32#issuecomment-817271948, or unsubscribehttps://github.com/notifications/unsubscribe-auth/ABNDOEKQPAHJUB5US3UFLY3TIFOK5ANCNFSM4LJGZ4SA.
Thank @nmoschkin very much! It is working now :)
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.
@nmoschkin Hey, thank you for the changes, they work great. Do you mind showing some sample code for the pageToken part? It's a bit confusing, thanks.
@marknasr22 Here is example code to download all the files in a folder
var pageToken = string.Empty;
do { var storageBucketList = storage.Child(folder).ListPrefixes(1000, pageToken).Result; foreach (var item in storageBucketList.Items) { var storageReference = item.GetReference(); var downloadUrl = storageReference.GetDownloadUrlAsync().Result; Task.Factory.StartNew(() => { var client = new HttpClient(); var resp = client.GetAsync(downloadUrl).Result;
var content = resp.Content.ReadAsStringAsync().Result.Trim();
if (!string.IsNullOrEmpty(content))
File.WriteAllText(item.Name, content);
}, cancellation.Token);
}
pageToken = storageBucketList.NextPageToken;
if (string.IsNullOrEmpty(pageToken)) break;
} while (true);
Thank you @hoangatpaygate
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.
Closing the issue due to inactivity. Feel free to re-open
Hello, is there any way to list all files?