lundi 11 juillet 2016

How can I get a list of files from FireBase Storage?

I just a newbie in Google Firebase. I loaded some audio files, and I want to make an access to it from my application to hear it in a stream. I have some troubles with it. I made a refrences, but if I want to do it - I have an 404 error.

protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    storage = FirebaseStorage.getInstance();
    storageRef = storage.getReferenceFromUrl("gs://musicmedia-f3b8d.appspot.com");
    audioRef = storageRef.child("audio");
    final List<FileDownloadTask> tasks = audioRef.getActiveDownloadTasks();
    for(FileDownloadTask task: tasks){
        names.add(task.getSnapshot().toString());
    }
    audioRef.getDownloadUrl().addOnSuccessListener(new OnSuccessListener<Uri>() {
@Override
public void onSuccess(Uri uri) {
    Toast.makeText(getBaseContext(), audioRef.getPath(),Toast.LENGTH_LONG).show();
    Log.d("Tag",audioRef.getName());
    for (int i = 0; i < tasks.size(); i++) {
        System.out.println(names.get(i).toString());
    }

}
});

}

Can you help me please?

Aucun commentaire:

Enregistrer un commentaire