Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Problems with listing files from a bucket: Duplicate path parts #50

Open
harel opened this issue Jan 10, 2024 · 0 comments
Open

Problems with listing files from a bucket: Duplicate path parts #50

harel opened this issue Jan 10, 2024 · 0 comments

Comments

@harel
Copy link

harel commented Jan 10, 2024

Hi,
I'm using this for an app that will predominantly run on a desktop (not mobile).
My files are stored in the default bucket, in a folder named audio at the root.

I can get all the files from that folder using a function like:

Future<ListResult> listAll() async {
  var app = await Firebase.initializeApp(
      options: FirebaseOptions.fromMap(json.decode(File('firebase-config.json').readAsStringSync()))
  );
  var storage = FirebaseStorage.instanceFor(app: app);
  var results = await storage.ref("audio").listAll();
  return results;
}

Note: Also tried with await.storage.ref().child('audio').listAll();

But when I loop the returning files, each one appears with the root folder "duplicated".
For example, the fullPath property of each Reference is audio/audio/file.mp3 instead of audio/file.mp3.
This results in a "file not found" when i'm trying to get a download url. The url comes as: gs://bucket-name.appspot.com/audio/audio/file.mp3 - with double audio/audio.

Update: I can get the right reference by doing something convoluted like: Reference? realItem = item.parent?.parent?.child(item.name); when looping the results, but that feels a bit off.

Any idea what I'm doing wrong?

Many thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant