Skip to content Skip to sidebar Skip to footer

How Can I Upload And Retrieve An Image To Firebase Storage In Android In 2018 (tasksnapshot/getdownloadurl Deprecated) (closed)

Update: my problem is solved now. How can i upload and retrieve an image to firebase storage in android in 2018 (taskSnapshot/getDownloadUrl deprecated).

Solution 1:

Finally, I got the solution. And its working pretty fine.

filePath.putFile(imageUri).addOnSuccessListener(newOnSuccessListener<UploadTask.TaskSnapshot>() {
    @OverridepublicvoidonSuccess(UploadTask.TaskSnapshot taskSnapshot) {
        filePath.getDownloadUrl().addOnSuccessListener(newOnSuccessListener<Uri>() {
            @OverridepublicvoidonSuccess(Uri uri) {
                Log.d(TAG, "onSuccess: uri= "+ uri.toString());
            }
        });
    }
});

Solution 2:

  imageFilesPath = storageReference.child("Your_collection Name" + "/"+ "Image_name"+ ".jpg");

  imageFilePath.putFile(image_Uri).addOnCompleteListener(newOnCompleteListener<UploadTask.TaskSnapshot>() {
        @OverridepublicvoidonComplete(@NonNull Task<UploadTask.TaskSnapshot> task) {
            if (task.isSuccessful() && task != null) {
                imageUrl = task.getResult().getDownloadUrl().toString();
          }
            }
    });

Solution 3:

Like @globlin said in this answer:

That method has been deprecated on version 16.0.1 (check Firebase release notes) so you have to use

StorageReference.getDownloadUr()

If you want to get them after uploading the file, then you must check their documentation here. It is already updated.

So, you can follow this guide to know how to do it in 2018.

Post a Comment for "How Can I Upload And Retrieve An Image To Firebase Storage In Android In 2018 (tasksnapshot/getdownloadurl Deprecated) (closed)"