-
Notifications
You must be signed in to change notification settings - Fork 712
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
getDownloadUrl Error #52
Comments
public void onSuccess(UploadTask.TaskSnapshot taskSnapshot) {
solved |
Sorted already sir thank you soo much . can please Tell the way how i can
get pdf download link on button from firebase
…On Fri 16 Nov, 2018, 8:58 PM Ahsan ***@***.*** wrote:
Here is the complete Else if block
`else if (requestCode == RC_PHOTO_PICKER && resultCode == RESULT_OK) {
Toast.makeText(this, "called!", Toast.LENGTH_SHORT).show();
Uri selectedImageUri = data.getData();
final StorageReference photoRef =
mChatPhotosStorageReference.child(selectedImageUri.getLastPathSegment());
Log.v(TAG, "PhotoReference" + photoRef.toString());
// Upload file to Firebase Storage
UploadTask uploadTask = photoRef.putFile(selectedImageUri);
Task<Uri> urlTask = uploadTask.continueWithTask(new Continuation<UploadTask.TaskSnapshot, Task<Uri>>() {
@OverRide
public Task<Uri> ***@***.*** Task<UploadTask.TaskSnapshot> task) throws Exception {
if (!task.isSuccessful()) {
throw task.getException();
}
// Continue with the task to get the download URL
return photoRef.getDownloadUrl();
}
}).addOnCompleteListener(new OnCompleteListener<Uri>() {
@OverRide
public void ***@***.*** Task<Uri> task) {
if (task.isSuccessful()) {
Uri downloadUri = task.getResult();
System.out.println("Upload " + downloadUri);
if (downloadUri != null) {
String photoStringLink = downloadUri.toString(); //YOU WILL GET THE DOWNLOAD URL HERE !!!!
System.out.println("Upload " + photoStringLink);
// Set the download URL to the message box, so that the user can send it to the database
FriendlyMessage friendlyMessage = new FriendlyMessage(null, mUsername, photoStringLink);
mMessagesDatabseReference.push().setValue(friendlyMessage);
}
} else {
// Handle failures
// ...
}
}
});
}`
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
<#52 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AT6z03KCoyhLrDC3X3OHGSV_kZZK7c9_ks5uvtm4gaJpZM4YDtZc>
.
|
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
StorageReference filepath=mStorage.child("T_image").child(mImageUri.getLastPathSegment());
filepath.putFile(mImageUri).addOnSuccessListener(new OnSuccessListener<UploadTask.TaskSnapshot>() {
@OverRide
public void onSuccess(UploadTask.TaskSnapshot taskSnapshot) {
Toast.makeText(upload_teach_info.this, "success", Toast.LENGTH_SHORT).show();
DatabaseReference new_add=mDatabase.push();
new_add.child("Name").setValue(mName);
new_add.child("Email").setValue(mEmail);
new_add.child("Desciption").setValue(mDesc);
new_add.child("Image").setValue(downloadUri.toString());
}
})
.addOnFailureListener(new OnFailureListener() {
@OverRide
public void onFailure(@nonnull Exception e) {
Toast.makeText(upload_teach_info.this, "failed!", Toast.LENGTH_SHORT).show();
}
});
The text was updated successfully, but these errors were encountered: