Comments (7)
@bighwstyle image not showing could be related to the .getDownloadUrl()
that has been deprecated. Hence, the friendlyMessage.imageUrl stores the wrong URL.
I solved it by using the following code to replace the putImageInStorage
function:
private void putImageInStorage(final StorageReference storageReference, Uri uri, final String key) {
UploadTask uploadTask = storageReference.putFile(uri);
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();
}
return storageReference.getDownloadUrl();
}
}).addOnCompleteListener(new OnCompleteListener<Uri>() {
@Override
public void onComplete(@NonNull Task<Uri> task) {
if (task.isSuccessful()) {
String downloadUrl = task.getResult().toString();
FriendlyMessage friendlyMessage = new FriendlyMessage(null, mUsername, mPhotoUrl,downloadUrl);
mFirebaseDatabaseReference.child(MESSAGES_CHILD).child(key).setValue(friendlyMessage);
} else {
Log.w(TAG, "Image upload task was not successful.",
task.getException());
}
}
});
from codelab-friendlychat-android.
Hi, you probably forgot to enable your storage in the firebase console. If you click on storage in the left menu and click on the get started button you should see this screen then everything will load fine.
from codelab-friendlychat-android.
Thanks @madmax330 for jumping in to help.
@leonidas79 did you ever get it working?
from codelab-friendlychat-android.
i tried upload other pictures and it's working , i tested it in emulator , not yet in real device.
from codelab-friendlychat-android.
Ok great, I think we can close this but @leonidas79 if you have any troubles on the real device just ping this thread and we can re-open it.
from codelab-friendlychat-android.
Is it closed? Image uploading is working. I can see it in the firebase console. But I can't see the pic after showing placeholder image.
from codelab-friendlychat-android.
hello,
If you have this problem, maybe is due to the rule:
rules_version = '2'; service firebase.storage { match /b/{bucket}/o { match /{allPaths=**} { allow read, write: if request.auth != null; } } }
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.