Skip to content
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

2.02.2 firebase storage put file #56

Open
wants to merge 9 commits into
base: 1.00-starting-point
Choose a base branch
from

Conversation

ark-srivastav
Copy link

@ark-srivastav ark-srivastav commented Dec 22, 2018

Implementing Updated Storage Put File and .getDownloadUrl()

        {
            Uri uri=data.getData();
            final StorageReference picref= mstorageReference.child(uri.getLastPathSegment());
            UploadTask uploadTask=picref.putFile(uri);
            Task<Uri> task=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 picref.getDownloadUrl();
                }
            }).addOnCompleteListener(new OnCompleteListener<Uri>() {
                @Override
                public void onComplete(@NonNull Task<Uri> task) {
                    if(task.isSuccessful())
                    {
                        Uri downloadUri=task.getResult();
                        mdatabaseReference.push().setValue(new FriendlyMessage(null,mUsername,downloadUri.toString()));
                    }
                }
            });
        }

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

10 participants