Open kuwarsingh opened 6 years ago
public void onSuccess(UploadTask.TaskSnapshot taskSnapshot) {
Task<Uri> dowmloadUrl =taskSnapshot.getStorage().getDownloadUrl();
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(dowmloadUrl.toString());
}
})
.addOnFailureListener(new OnFailureListener() {
@Override
public void onFailure(@NonNull Exception e) {
Toast.makeText(upload_teach_info.this, "failed!", Toast.LENGTH_SHORT).show();
}
});
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 <notifications@github.com 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> then(@NonNull 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 onComplete(@NonNull 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 https://github.com/udacity/and-nd-firebase/issues/52#issuecomment-439428919, or mute the thread https://github.com/notifications/unsubscribe-auth/AT6z03KCoyhLrDC3X3OHGSV_kZZK7c9_ks5uvtm4gaJpZM4YDtZc .
StorageReference filepath=mStorage.child("T_image").child(mImageUri.getLastPathSegment()); filepath.putFile(mImageUri).addOnSuccessListener(new OnSuccessListener() {
@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();
}
});