I use Firebase Storage to upfile
. But it does not work
THIS IS MY CODE.
FirebaseStorage storage = FirebaseStorage.getInstance();
StorageReference storageRef = storage.getReferenceFromUrl("gs://the-food-house.appspot.com/");
// Create a reference to "file"
StorageReference mStorage = storageRef.child("Album Avatar")
.child(UserUID)
.child(AvatarUser.getLastPathSegment());
mStorage.putFile(AvatarUser).addOnSuccessListener(new OnSuccessListener<UploadTask.TaskSnapshot>() {
@Override
public void onSuccess(UploadTask.TaskSnapshot taskSnapshot) {
Toast.makeText(SignUpWithEmail.this, "UPLOAD FILE OK", Toast.LENGTH_SHORT).show();
}
}).addOnFailureListener(new OnFailureListener() {
@Override
public void onFailure(@NonNull Exception e) {
Log.d("ERROR", e.toString());
Toast.makeText(SignUpWithEmail.this, "Failed", Toast.LENGTH_SHORT).show();
}
};
Here is the error I am having:
com.google.firebase.storage.StorageException: An unknown error occurred, please check the HTTP result code and inner exception for server response.
And this is details of error:
Unrecognized GLES max version string in extensions: ANDROID_EMU_CHECKSUM_HELPER_v1 ANDROID_EMU_dma_v1
E/UploadTask: could not locate file for uploading:https://firebasestorage.googleapis.com/v0/b/the-food-house.appspot.com/o/Avatar%20Default%2Fmale.png?alt=media&token=3f285cab-c32b-4f33-a909-5a85ef62d74d
E/StorageException: StorageException has occurred.
An unknown error occurred, please check the HTTP result code and inner exception for server response.
Code: -13000 HttpResult: 0
E/StorageException: No content provider: https://firebasestorage.googleapis.com/v0/b/the-food-house.appspot.com/o/Avatar%20Default%2Fmale.png?alt=media&token=3f285cab-c32b-4f33-a909-5a85ef62d74d
java.io.FileNotFoundException: No content provider: https://firebasestorage.googleapis.com/v0/b/the-food-house.appspot.com/o/Avatar%20Default%2Fmale.png?alt=media&token=3f285cab-c32b-4f33-a909-5a85ef62d74d
at android.content.ContentResolver.openTypedAssetFileDescriptor(ContentResolver.java:1131)
at android.content.ContentResolver.openAssetFileDescriptor(ContentResolver.java:982)
at android.content.ContentResolver.openInputStream(ContentResolver.java:702)
at com.google.firebase.storage.UploadTask.<init>(Unknown Source)
at com.google.firebase.storage.StorageReference.putFile(Unknown Source)
at thedark.example.com.thefoodhouse.Activity.Authencation.SignUpWithEmail.submitAvatarStorage(SignUpWithEmail.java:111)
at thedark.example.com.thefoodhouse.Activity.Authencation.SignUpWithEmail.access$1200(SignUpWithEmail.java:38)
at thedark.example.com.thefoodhouse.Activity.Authencation.SignUpWithEmail$5.onComplete(SignUpWithEmail.java:170)
at com.google.android.gms.tasks.zzf.run(Unknown Source)
at android.os.Handler.handleCallback(Handler.java:751)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:154)
at android.app.ActivityThread.main(ActivityThread.java:6077)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:866)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:756)
This is rule firebase:
allow read, write: if request.auth != null;
It has given me a headache these past few days. Hope that someone finds the problem. Help me please. Thank you.