I've send a imageUri to the final acivity and show it on my imageview, and when i want to upload the image to storage, its show me content://media/external/images/media/9863" that's look like this
how can i send the image to firebase storage and get the imageUri, because when i try this, they say can't complete cause of the string type
the imageUri
was the string that i've send to my final activity, and when i show it to the imageView, the picture showup, but when i get the data from imageview they give me local storage location instead of download url
i've read this How to get the download url from Firebase Storage? but this is for getting the download url from firebase storage. i want to get the bitmap and upload it first to my storage firebase
CodePudding user response:
oh im using this as the answer of the top question
private void uploadToFirebase(Uri uri) {
StorageReference fileRef = ref.child (System.currentTimeMillis () "." getFileExtension(uri));
fileRef.putFile (uri).addOnSuccessListener (new OnSuccessListener<UploadTask.TaskSnapshot> ( ) {
@Override
public void onSuccess(UploadTask.TaskSnapshot taskSnapshot) {
fileRef.getDownloadUrl ().addOnSuccessListener (new OnSuccessListener<Uri> ( ) {
@Override
public void onSuccess(Uri uri) {
Model model = new Model ( uri.toString () );
root.child(currentDateandTime).child("GambarDokumen").child("KTP").setValue(model);
finish();
}
});
}
}).addOnProgressListener (new OnProgressListener<UploadTask.TaskSnapshot> ( ) {
@Override
public void onProgress(@NonNull UploadTask.TaskSnapshot snapshot) {
}
}).addOnFailureListener (new OnFailureListener ( ) {
@Override
public void onFailure(@NonNull Exception e) {
}
});
}
and its work properly/how the way i want now
CodePudding user response:
If you need to upload image to server:-
you have to option:-
1)Fast upload image to any storage server and get the image URL and store the URL to your database.
2)Convert the image to byte code and save it to your database.
i recommend you the number 1 option.(This is Good Practice Always)