0

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?

Nancy Khorevich
  • 53
  • 2
  • 11
  • 1
    Am I right that you want to get a list of files from your folder? In this case you should check this http://stackoverflow.com/questions/37335102/how-to-get-an-array-with-all-pictures – user1835337 Jun 26 '16 at 19:33
  • As @user1835337 hinted/linked: there is no API to get a list of files in a Firebase Storage folder. You'll have to store them somewhere, such as for example in the Firebase Database or in a local database on your Android device. Calling `getActiveDownloadTasks()` will just get you a list of active downloads, which likely is empty. – Frank van Puffelen Jun 26 '16 at 22:10
  • Yes, I tried to use it, but I had some roubles with it too – Nancy Khorevich Jun 27 '16 at 03:49
  • The problem of this answer http://stackoverflow.com/questions/37335102/how-to-get-an-array-with-all-pictures - that I don't need to upload some pictures or etc. I already have files in Storage and I want to use it in Database – Nancy Khorevich Jul 01 '16 at 07:11

0 Answers0