-
Notifications
You must be signed in to change notification settings - Fork 714
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
UploadTask.TaskSnapshot doesn't have getDownloadUrl() method #41
Comments
Yes they deprecated and then removed that method.
|
Have a look here. Its as simple as using your storageRef to get the download url on condition the task was successfull.
Note the
In place of
|
I try to do it like this ↓↓↓ can work. Thanks @Parthav46 Uri uri = data.getData();
if (uri != null) {
final StorageReference imgReference = mChatPhotosStorageReference.child(uri.getLastPathSegment());
UploadTask uploadTask = imgReference.putFile(uri);
uploadTask.continueWithTask(new Continuation<UploadTask.TaskSnapshot, Task<Uri>>() {
@Override
public Task<Uri> then(@NonNull Task<UploadTask.TaskSnapshot> task) throws Exception {
if (!task.isSuccessful()) {
throw task.getException();
}
return imgReference.getDownloadUrl();
}
}).addOnCompleteListener(new OnCompleteListener<Uri>() {
@Override
public void onComplete(@NonNull Task<Uri> task) {
if (task.isSuccessful()) {
Uri taskResult = task.getResult();
FriendlyMessage message = new FriendlyMessage(null, mUsername, taskResult.toString());
mMessagesDatabaseReference.push().setValue(message);
}
}
});
} |
@DevRyz3n running this command would raise FileNotFoundException as the returned value is not the download url for file.
|
i am currently having the same problem public class FirebaseStorageHelper {
} |
Hello @mfgabriel92 does it work? I mean when you changed the onSucces() implementation? |
` import android.content.Intent; import com.google.android.gms.tasks.Continuation; import java.util.ArrayList; public class MainActivity extends AppCompatActivity {
}` I use this code. but it does not store the photos in firebase. Not showing anything, but the app is not crashed. Help me to fix this. |
@achyutghosh You should write resultCode |
How can i thumb the using your procedure and using continuWithtask() ?? Can you help me ? |
How can i thumb the using your procedure and using continuWithtask() ?? Can you help me ? |
filePath.putFile(resultUri).addOnCompleteListener(new OnCompleteListener<UploadTask.TaskSnapshot>() { |
I have tried running this code and it finally got rid of the dreadful .getDownloadUrl error but the photo still will not store or display in the chat :'( Did anyone else get their app to work? |
Try this, works good !!!!!!! believe me... put this in the onActivityResult method...:) |
Try this code, it works for me `
` |
there has a same error, i can't understand how to fix that.please help setupBtn.setOnClickListener( new View.OnClickListener() {
|
@Parthav46 i tried |
@ChutiBro try this
|
Hey guys, Try this code, it works for me:
|
This solution works best! for getting the photos to upload and store in the database! :) The .getDownloadURL is no longer available and deprecated. |
How to get downloadUrl for Multiple files? |
you can use that .... String download_url= task.getResult().getUploadSessionUri().toString(); |
This issue could be closed I think. 😄 |
I faced the same problem but I got the answer Just add to be like this below
LEAVE EVERYTHING IN THAT LINE DONT ALTER JUST ADD |
thank you it works fine now
…On Sat, Feb 9, 2019 at 8:34 AM KEVIN koech ***@***.***> wrote:
I faced the same problem but I got the answer
Just add .getStorage() infront of .getDownloadurl
to be like this below
.getStorage().getDownloadUrl
LEAVE EVERYTHING IN THAT LINE DONT ALTER JUST ADD .getStorage()
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
<#41 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AmiUaWdFDY-lerHYHxorFLL0a8cZwsmWks5vLsBhgaJpZM4URmLi>
.
|
welcome |
This definitely worked! |
package com.saggemode; import androidx.annotation.NonNull; import android.app.ProgressDialog; import com.google.android.gms.tasks.OnCompleteListener; import java.util.HashMap; import de.hdodenhof.circleimageview.CircleImageView; public class SettingsActivity extends AppCompatActivity {
} |
My solution. The download address was "com.google.android.gms.tasks ...", so I couldn't use it with Glide. I've reviewed shared solutions. . I have reached this solution by following the path below.Maybe it's an inspiration. Thank's all. 🧸 mStorageRef.child("users").child(getUserInfo.userUID!!)
.child(profilePictureSelectedUri!!.lastPathSegment!!)
.putFile(profilePictureSelectedUri!!)
.addOnSuccessListener { itUploadTask ->
itUploadTask?.storage?.downloadUrl?.addOnSuccessListener { itUri ->
val downloadUrl: String = itUri.toString()
mDatabaseRef.child("users").child(getUserInfo.userUID!!)
.child("userDetails")
.child("userProfilePicture")
.setValue(downloadUrl).addOnCompleteListener { itTask ->
if (itTask.isSuccessful) {
//profileUpdateController = true -> it was necessary for me
dialogPictureFragmentProgressFragment.dismiss()
mStorageRef.downloadUrl
} else {
val message = itTask.exception?.message
Toast.makeText(
activity!!,
"Error Occured..." + message,
Toast.LENGTH_SHORT
).show()
}
}
}
} Helper : https://firebase.google.com/docs/storage/android/download-files#download_data_via_url |
the getDownloadURL() is not inside the AngularFireUploadTask.. It is inside AngularFireStorageReference. Right click on the AngularFireStorageReference and click "Go to definition" you will find that method in there. |
can some body please send me back the file with all the updates thank you
in advance
…On Thu, Jul 18, 2019 at 1:49 AM Razalimustapa ***@***.***> wrote:
the getDownloadURL() is not inside the AngularFireUploadTask.. It is
inside AngularFireStorageReference. Right click on the
AngularFireStorageReference and click "Go to definition" you will find that
method in there.
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
<#41?email_source=notifications&email_token=AJUJI2KAAO2B4YVQDACLHTDP77Y7DA5CNFSM4FCGMLRKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOD2HKA4Y#issuecomment-512663667>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AJUJI2P2YHDNRIAVXJNWELDP77Y7DANCNFSM4FCGMLRA>
.
|
this code working in angular8uploadfile(event:any){
const storageRef:firebase.storage.Reference =firebase.storage().ref('/photos')
} |
I got it with this solution
|
Hey guys, is that issues still open? Before and after, you can compare both at glance. |
taskSnapshot.uploadSessionUri.toString() |
thanks 1000 times Parthav46 private StorageReference userProfileImageRef; userProfileImageRef = FirebaseStorage.getInstance().getReference().child( "Images" ); final StorageReference filePath = userProfileImageRef.child( userId + ".jpg" ); |
To get non null segment you need to use API 19 (KITKAT) and need to use NonNullException and asserts Uri selectedImageUri = data.getData();
|
fun upload(view: View){
|
Just write this:- |
this did the trick |
Why |
I'm following a tutorial teaching how to upload images to Firebase. At certain moment the instructor will write the code to get the download URL after uploading by using
getDownloadUrl()
method fromUploadTask.TaskSnapshot
, but for me, this method doesn't exist.Based on another code I found, I tried the following:
Because it is similar to what's shown in the documentation, but I didn't understand it very well. How to implement it?
The text was updated successfully, but these errors were encountered: