0

I am using the following method to save information.

    private void saveUserData() {
    progressDialog.setTitle("Account Settings");
    progressDialog.setMessage("Please wait while settings are being changed...");
    progressDialog.show();

    final StorageReference imageRef = storageReference
            .child(FirebaseAuth.getInstance().getCurrentUser().getUid());
    imageRef.putFile(imageUri);
}

I have removed some lines of code for accessing the database.

This the log cat description.

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/AndroidRuntime: FATAL EXCEPTION: FirebaseStorage-Upload-1

I seached this error code and found

case unknown = -13000

The app doesn't crash when I comment this line.

imageRef.putFile(imageUri);

On a side note, I am able to save text info successfully and even retrieve it from the database.

EDIT

Here is the code.

 protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_settings);

    storageReference = FirebaseStorage.getInstance()
            .getReference().child("Profile Pictures");

    profileImageView.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            Intent intent = new Intent();
            intent.setAction(Intent.ACTION_GET_CONTENT);
            intent.setType("image/*");
            startActivityForResult(intent, galleryPick);
        }
    });
    saveButton.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            saveUserData();
        }
    });
    retrieveUserInformation();
}

protected void onActivityResult(int requestCode, int resultCode, @Nullable Intent data) {
    super.onActivityResult(requestCode, resultCode, data);

    if (requestCode == galleryPick && resultCode == RESULT_OK && data != null) {
        imageUri = data.getData();
        profileImageView.setImageURI(imageUri);
    }
}
3
  • 3
    Please provide more code. I try to check the bug from this code but not enough data. maybe it's was bug on another line such as storageReference is not initial correctly FirebaseStorage firebaseStorage = FirebaseStorage.getInstance() ??? about .getInstance() ??? Commented Jun 16, 2020 at 2:24
  • Given the variable name imageUri, you're trying to upload to Storage from a URL, which is not supported. You'll first have to download the data from the URL, and then upload it to Storage. Commented Jun 16, 2020 at 3:49
  • @FrankvanPuffelen I appreciate your support. But, stackoverflow.com/questions/48433212/… the person is able to do upload using Uri. Commented Jun 20, 2020 at 13:42

1 Answer 1

1

Given the variable name imageUri, you're trying to upload to Storage from a URL, which is not supported. You'll first have to download the data from the URL, and then upload it to Storage.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.