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

How to upload image from local to firebase #60

Open
ggafiled opened this issue Mar 16, 2019 · 4 comments
Open

How to upload image from local to firebase #60

ggafiled opened this issue Mar 16, 2019 · 4 comments

Comments

@ggafiled
Copy link

i want to upload image from device to firebase storge and get url like upload from internet

@chinalwb
Copy link
Owner

See this Callback for image upload #56 .

Let me know if that helps.

@ggafiled
Copy link
Author

Thank you, I will check it again.

@ggafiled
Copy link
Author

@chinalwb

this line mStorageRef.child(userid+".jpg").putFile("???????????????") i try to add uris to function and it error . what is virrible that i can put image (in .putFile("???????????????"))

@OverRide
protected String doInBackground(Uri... uris) {
if (uris != null && uris.length > 0) {
try {
mStorageRef.child(userid+".jpg").putFile("???????????????").continueWithTask(new Continuation<UploadTask.TaskSnapshot, Task>() {
@OverRide
public Task then(@nonnull Task<UploadTask.TaskSnapshot> task) throws Exception {
if (!task.isSuccessful()) {
throw task.getException();
}
return mStorageRef.child(userid+".jpg").getDownloadUrl();
}
}).addOnCompleteListener(new OnCompleteListener() {
@OverRide
public void onComplete(@nonnull Task task) {
if(task.isSuccessful()){
ImageProfileUri = task.getResult();
}else{
Log.i("Newstory",task.getException().getMessage());
}
}
});
} catch (Exception e) {
e.printStackTrace();
}

            // Returns the image url on server here
            return ImageProfileUri.toString();
        }
        return null;
    }

@chinalwb
Copy link
Owner

Sorry I don't know much about firebase storage.

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

No branches or pull requests

2 participants