Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

FirebaseStorage returning unknown error when requesting image

I am trying to pull in an image I have added to my firebase storage on an Android device. Every time this runs I get this error from the onFailureListener()

E/StorageException(9646): An unknown error occurred, please check the HTTP result code and inner exception for server response. E/StorageException(9646): Code: -13000 HttpResult: 0

I have also changed the permissions on storage to have read/write for the time being to make sure that isn't the problem.

final ImageView test = (ImageView) findViewById(R.id.test_image);
StorageReference ref = storage.getReferenceFromUrl("gs://my-project.appspot.com/test_image.png");
    ref.getDownloadUrl().addOnSuccessListener(new OnSuccessListener<Uri>() {
        @Override
        public void onSuccess(Uri uri) {
            Log.d(TAG, "Successfully loaded uri");
            test.setImageURI(uri);
        }
    }).addOnFailureListener(new OnFailureListener() {
        @Override
        public void onFailure(@NonNull Exception e) {
            Log.d(TAG, "Failed loaded uri: " + e.getMessage());
        }
    });
like image 933
johnsoe Avatar asked May 23 '16 16:05

johnsoe


People also ask

How can I get image URL from Firebase storage web?

Image URL is obtained by uploading an image to firebase bucket and then that can return back a URL that URL is a permanent URL which can be open anywhere. Then a user can use this URL for any purpose in its application.

How can I get download URL from Firebase storage?

Once you have a reference, you can download files from Cloud Storage by calling the getBytes() or getStream() . If you prefer to download the file with another library, you can get a download URL with getDownloadUrl() .


1 Answers

I just noticed that the httpresult is zero. This suggests the request to get the download url was never made. One way this can happen is if play services isn't updated on your phone. You will know this is the error because adb logcat will show an error with something to the effect of "Storage network layer could not be loaded".

To fix this, update play services on your phone. There are a few ways of doing this. I find the easiest is to install the app "play services info" to see play services in the play store, and then hit update if its available.

like image 80
Benjamin Wulfe Avatar answered Oct 13 '22 18:10

Benjamin Wulfe