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());
}
});
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.
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() .
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With