Comments (21)
Fixed
replace task.getResult().getMetadata().getDownloadUrl()
by task.getResult().getStorage()().getDownloadUrl()
Reason is mentioned on StackOverflow:
The getDownloadUrl() and getDownloadUrls() methods of the StorageMetadata class are now deprecated. Use getDownloadUrl() from StorageReference instead.
from codelab-friendlychat-android.
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()
from codelab-friendlychat-android.
Fixed
replace
task.getResult().getMetadata().getDownloadUrl()
bytask.getResult().getStorage()().getDownloadUrl()
Reason is mentioned on StackOverflow:
The getDownloadUrl() and getDownloadUrls() methods of the StorageMetadata class are now deprecated. Use getDownloadUrl() from StorageReference instead.
Thanks Bro !
from codelab-friendlychat-android.
Can you share the error?
from codelab-friendlychat-android.
I am also getting the same error on Android Studio 3.1.2
In method putImageInStorage of MainActivity
@Override
public void onComplete(@NonNull Task<UploadTask.TaskSnapshot> task) {
if (task.isSuccessful()) {
FriendlyMessage friendlyMessage =
new FriendlyMessage(null, mUsername, mPhotoUrl,
task.getResult().getMetadata().getDownloadUrl()
.toString());
mFirebaseDatabaseReference.child(MESSAGES_CHILD).child(key)
.setValue(friendlyMessage);
} else {
Log.w(TAG, "Image upload task was not successful.",
task.getException());
}
}
getDownloadUrl() of task.getResult().getMetadata().getDownloadUrl()
is giving error "cannot resolve method 'getDownloadUrl()' "
from codelab-friendlychat-android.
Thanks @ankode it's worked.
from codelab-friendlychat-android.
you can find the solution here: https://stackoverflow.com/a/51076403/3135287
from codelab-friendlychat-android.
I had tried to help people on stackoverflow to answer this but they raised my reputation higher so I cant answer there...too bad
from codelab-friendlychat-android.
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()
this code saved me thank you so much
from codelab-friendlychat-android.
Just replace from taskSnapshot.getDownloadUrl().toString() to mImageUri.toString() it works thanks
or use
taskSnapshot.getMetadata().getReference().getDownloadUrl().toString()
from codelab-friendlychat-android.
I want
task.getResult().getDownloadUrl().toString() -----> this statement
task.getResult().getStorage().getDownloadUrl().toString() -----> this is works and doesn't shows any error but in app I try to open its crashes.
So, What can I do friends.?
from codelab-friendlychat-android.
i have a problem , after a long search i din't a suitable solution
ca not resolve getdonwloadUrl()
please help me
.addOnSuccessListener(new OnSuccessListener<UploadTask.TaskSnapshot>() {
@OverRide
public void onSuccess(UploadTask.TaskSnapshot taskSnapshot) {
// Upload succeeded
Log.d(TAG, "OnSuccessListener");
Uri downloadUri = taskSnapshot.getMetadata().getDownloadUrl();
Log.d(TAG, "downloadUri: " + downloadUri);
pdfsize = taskSnapshot.getMetadata().getSizeBytes();
pdfsize = pdfsize/1048576;
Log.d(TAG, "onSuccess: fileSize"+pdfsize);
uploaddate = FindCurrentDate();
Toast.makeText(MyUploadService.this, getString(R.string.upload_success), Toast.LENGTH_LONG).show();
uploadOnDB(downloadUri.toString(), pdfref.getName());
broadcastUploadFinished(downloadUri, fileUri);
showUploadFinishedNotification(pdfname, downloadUri, fileUri);
taskCompleted();
}
})
from codelab-friendlychat-android.
my code isn´t working can you help me?
here is my code:
private void saveToStories() {
final DatabaseReference userStoryDb = FirebaseDatabase.getInstance().getReference().child("users").child(Uid).child("story");
final String key = userStoryDb.push().getKey();
StorageReference filePath = FirebaseStorage.getInstance().getReference().child("captures").child(key);
ByteArrayOutputStream baos = new ByteArrayOutputStream();
rotateBitmap.compress(Bitmap.CompressFormat.JPEG, 20, baos);
byte[] dataToUpload = baos.toByteArray();
UploadTask uploadTask = filePath.putBytes(dataToUpload);
uploadTask.addOnSuccessListener(new OnSuccessListener<UploadTask.TaskSnapshot>() {
@Override
public void onSuccess(UploadTask.TaskSnapshot taskSnapshot) {
Uri imageUrl = taskSnapshot.getDownloadUrl();
Long currentTimestamp = System.currentTimeMillis();
Long endTimestamp = currentTimestamp + (24*60*60*1000);
Map<String, Object> mapToUpload = new HashMap<>();
mapToUpload.put("imageUrl", imageUrl.toString());
mapToUpload.put("timestampBeg", currentTimestamp);
mapToUpload.put("timestampEnd", endTimestamp);
userStoryDb.child(key).setValue(mapToUpload);
finish();
return;
}
});
uploadTask.addOnFailureListener(new OnFailureListener() {
@Override
public void onFailure(@NonNull Exception e) {
finish();
return;
}
});
}
from codelab-friendlychat-android.
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()
this code saved me thank you so much
it is not giving valid URL for me
from codelab-friendlychat-android.
val downloadUrl = taskSnapshot.downloadUrl
this taskSnapshot.downloadUrl shows me error please anyone can help??
my image is not saved in firebase only this error in my code please help
from codelab-friendlychat-android.
i did this instead and it resolved the problem for me
Task task = taskSnapshot.getMetadata().getReference().getDownloadUrl();
task.addOnSuccessListener(new OnSuccessListener() {
@OverRide
public void onSuccess(Uri uri) {
String url = uri.toString();
}
first i uploaded the image to storage and then i fetch the url using this method to place it in the database.
from codelab-friendlychat-android.
taskSnapshot.getMetadata().getReference().getDownloadUrl().toString() use this it worked for me
from codelab-friendlychat-android.
taskSnapshot.getMetadata().getReference().getDownloadUrl().toString() and also use taskSnapshot.getStorage().getDownloadUrl().toString() this it is not worked for me could you help me
from codelab-friendlychat-android.
taskSnapshot.getMetadata().getReference().getDownloadUrl().toString() and also use taskSnapshot.getStorage().getDownloadUrl().toString() this it is not worked for me could you help me
Task task = taskSnapshot.getMetadata().getReference().getDownloadUrl();
task.addOnSuccessListener(new OnSuccessListener() {
@OverRide
public void onSuccess(Uri uri) {
String url = uri.toString();
}
try this
from codelab-friendlychat-android.
This work very well and easy way to write code for uploading and downloading image file.
Uri selectedImageUri = data.getData();
final StorageReference photoRef = mChatStorageReference.child(selectedImageUri.getLastPathSegment());
//This line of code is actually upload photo to database storage
photoRef.putFile(selectedImageUri).addOnSuccessListener(new OnSuccessListener<UploadTask.TaskSnapshot>() {
@Override
public void onSuccess(UploadTask.TaskSnapshot taskSnapshot) {
Toast.makeText(MainActivity.this, "Image Successfully uploaded", Toast.LENGTH_SHORT).show();
photoRef.getDownloadUrl().addOnSuccessListener(new OnSuccessListener<Uri>() {
@Override
public void onSuccess(Uri uri) {
FriendlyMessage friendlyMessage = new FriendlyMessage(null, mUsername, uri.toString());
mMessagesDatabaseReference.push().setValue(friendlyMessage);
}
});
}
}).addOnFailureListener(new OnFailureListener() {
@Override
public void onFailure(@NonNull Exception e) {
Toast.makeText(MainActivity.this, "Image Fail to upload", Toast.LENGTH_SHORT).show();
}
});
from codelab-friendlychat-android.
from codelab-friendlychat-android.
Related Issues (20)
- I separated the Java and Kotlin version HOT 2
- default_web_client_id HOT 2
- Replace startActivityForResult
- Add more stringent Cloud Storage rules HOT 1
- If done to exact spec, App will crash on launch. HOT 2
- Include code for goToMainActivity()
- No instruction on `private fun signIn` in SignInActivity.kt
- mock-google-services file missing HOT 1
- API key not valid HOT 11
- messageImageView typo in step 7 HOT 5
- Why my getDownloadUrl() has error ? HOT 5
- AuthUI.getInstance().signOut() missing 'this' HOT 1
- LinearLayoutManager tends to crash when new image inserted HOT 3
- USB Debugging
- Sign in with email: NEXT button does not work HOT 1
- Don't have gradle version 8.0.2
- Can't copy mock-google-services.json file to build-android-start/app folder
- Kepp getting error code 10 when logging with Google account
- MainActivity crash because of 'the default_web_client_id string wasn't populated' HOT 1
- com.firebaseui:firebase-ui-auth needs an upgrade HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from codelab-friendlychat-android.