Skip to content
Advertisement

Firebase Storage Code: -13000 HttpResult: 0

When I try to upload an image to the storage I get this error :

Error

I have already tried changing the dependencies and the versions but nothing has changed. I have also tried several times to modify my code by removing or modifying a part but always the same error coming back.

Here is the code which manages the selection of the photo and sends it to the sockage. I also have the line firebaseStorage = FirebaseStorage.getInstance(); at the top of my code but this one is 400 lines long so I won’t post the whole code.

    @Override
public void onActivityResult(int requestCode, int resultCode, @Nullable Intent data) {          // Crop selected photo
    super.onActivityResult(requestCode, resultCode, data);
    if (requestCode == CropImage.CROP_IMAGE_ACTIVITY_REQUEST_CODE) {
        CropImage.ActivityResult result = CropImage.getActivityResult(data);
        if (resultCode == RESULT_OK) {
            resultUri = result.getUri();
            profileImage.setImageURI(resultUri);
        } else if (resultCode == CropImage.CROP_IMAGE_ACTIVITY_RESULT_ERROR_CODE) {
            Exception error = result.getError();
        }
    }
}

private void addPictureFirebase() {                                                             // Add photo to storage
    storageReference = firebaseStorage.getReference();
    myReference = storageReference.child(userUid);

    storageReference.getName().equals(myReference.getName());

    if (resultUri == null) {
        Toast.makeText(getActivity(), "Sélectionner d'abord une photo"+resultUri, Toast.LENGTH_SHORT).show();
    } else {
        storageReference.putFile(resultUri).addOnSuccessListener(new OnSuccessListener<UploadTask.TaskSnapshot>() {
            @Override
            public void onSuccess(UploadTask.TaskSnapshot taskSnapshot) {
                Toast.makeText(getActivity(), "Photo envoyée avec succès !", Toast.LENGTH_SHORT).show();
            }
        });
        storageReference.putFile(resultUri).addOnFailureListener(new OnFailureListener() {
            @Override
            public void onFailure(@NonNull Exception e) {
                Toast.makeText(getActivity(), "Erreur", Toast.LENGTH_SHORT).show();
            }
        });
    }

Advertisement

Answer

Replace this

storageReference.putFile(resultUri).addSuccessListener()

With this

myReference.putFile(resultUri).addSuccessListener()

User contributions licensed under: CC BY-SA
1 People found this is helpful
Advertisement