0
votes

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);
    }
}
1
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() ???s. srichomthong
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.Frank van Puffelen
@FrankvanPuffelen I appreciate your support. But, stackoverflow.com/questions/48433212/… the person is able to do upload using Uri.Aman Atman

1 Answers

1
votes

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.