Skip to content

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

Description

@harel

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!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions