I'm trying to store an image that I downloaded from google to firebase storage I'm not really sure what I'm doing wrong.
I'm getting this error " An unknown error occurred, please check the HTTP result code and inner exception for server response."
E/UploadTask: could not locate file for uploading:file:///images
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: /images: open failed: ENOENT (No such file or directory)
java.io.FileNotFoundException: /images: open failed: ENOENT (No such file or directory)
this my code:
private void saveImgToStorage() {
if (imageUri != null) {
imageUri = Uri.fromFile(new File("images"));
imgRef = storageReference.child("images");
imgRef.putFile(imageUri).addOnSuccessListener(new OnSuccessListener<UploadTask.TaskSnapshot > () {
@Override
public void onSuccess(UploadTask.TaskSnapshot taskSnapshot) {
Toast.makeText(getContext(), "STORED IMAGE", Toast.LENGTH_SHORT).show();
}
}).addOnFailureListener(new OnFailureListener() {
@Override
public void onFailure(@NonNull Exception e) {
Toast.makeText(getContext(), "FAILED TO STORE IMAGE " + e.getMessage(), Toast.LENGTH_SHORT).show();
}
});
}
}
Storage Rules:
rules_version = '2';
service firebase.storage {
match /b/{bucket}/o {
match /{allPaths=**} {
allow read, write: if true;
}
}
}