-2

Any assistance would be greatly appreciated! (unlike DownloadURL() which is depreciated)

The issue started when i updated Android Studio and moved all my code over to AndroidX material design support library. (was not expecting so much rebuilding)

Here is my current set up:

 Log.d(TAG, "uploadNewPhoto: attempting to upload new photo"); FilePaths filePaths = new FilePaths(); //Case 1 new photo if (photoType.equals(mContext.getString(R.string.profile_photo))){ String user_id = FirebaseAuth.getInstance().getCurrentUser().getUid(); StorageReference storageReference = mStorageReference .child(filePaths.FIREBASE_IMAGE_STORAGE + "/" + user_id + "/photo" + (count + 1)); //Convert image url to bitmap Bitmap bm = ImageManager.getBitmap(imgUrl); byte[] bytes = ImageManager.getBytesFromBitmap(bm, 100); UploadTask uploadTask = null; uploadTask = storageReference.putBytes(bytes); uploadTask.addOnSuccessListener(new OnSuccessListener<UploadTask.TaskSnapshot>() { @Override public void onSuccess(UploadTask.TaskSnapshot taskSnapshot) { ****Uri filebaseUrl = taskSnapshot.getDownloadUrl();**** Toast.makeText(mContext, "Photo Upload Success!", Toast.LENGTH_SHORT).show(); //add new photo to photos node and user_photos node //navigate to main feed so user can see photo } }).addOnFailureListener(new OnFailureListener() { @Override public void onFailure(@NonNull Exception e) { Log.d(TAG, "onFailure: Photo upload failed."); Toast.makeText(mContext, "Photo upload failed. ", Toast.LENGTH_SHORT).show(); } }).addOnProgressListener(new OnProgressListener<UploadTask.TaskSnapshot>() { @Override public void onProgress(@NonNull UploadTask.TaskSnapshot taskSnapshot) { double progress = (100 * taskSnapshot.getBytesTransferred()) / taskSnapshot.getTotalByteCount(); if (progress - 15 > mPhotoUploadProgress){ Toast.makeText(mContext, "photo upload progress: " + String.format("%.0f", progress) + "%", Toast.LENGTH_SHORT).show(); mPhotoUploadProgress = progress; } } }); }else if (photoType.equals(mContext.getString(R.string.profile_photo))){ } //case 2 new profile photo } 
1
  • See this Commented Nov 28, 2019 at 22:59

1 Answer 1

0

Solution Found on Related Issue ->

Replace:

Uri filebaseUrl = taskSnapshot.getDownloadUrl(); 

With

Task<Uri> firebaseUri = taskSnapshot.getStorage().getDownloadUrl(); 
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.