Giter Club home page Giter Club logo

Comments (7)

marwazihs avatar marwazihs commented on August 23, 2024 4

@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.

madmax330 avatar madmax330 commented on August 23, 2024 3

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.
screen shot 2018-02-16 at 8 58 24 am

from codelab-friendlychat-android.

samtstern avatar samtstern commented on August 23, 2024

Thanks @madmax330 for jumping in to help.

@leonidas79 did you ever get it working?

from codelab-friendlychat-android.

leonidas79 avatar leonidas79 commented on August 23, 2024

i tried upload other pictures and it's working , i tested it in emulator , not yet in real device.

from codelab-friendlychat-android.

samtstern avatar samtstern commented on August 23, 2024

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.

 avatar commented on August 23, 2024

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.

HALLneufmilles avatar HALLneufmilles commented on August 23, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.