Android-Rich-text-Editor icon indicating copy to clipboard operation
Android-Rich-text-Editor copied to clipboard

How to upload image from local to firebase

Open ggafiled opened this issue 6 years ago • 4 comments

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

ggafiled avatar Mar 16 '19 06:03 ggafiled

See this Callback for image upload #56 .

Let me know if that helps.

chinalwb avatar Mar 16 '19 10:03 chinalwb

Thank you, I will check it again.

ggafiled avatar Mar 17 '19 23:03 ggafiled

@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<Uri>>() { @Override public Task<Uri> then(@NonNull Task<UploadTask.TaskSnapshot> task) throws Exception { if (!task.isSuccessful()) { throw task.getException(); } return mStorageRef.child(userid+".jpg").getDownloadUrl(); } }).addOnCompleteListener(new OnCompleteListener<Uri>() { @Override public void onComplete(@NonNull Task<Uri> 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;
    }

ggafiled avatar Mar 18 '19 07:03 ggafiled

Sorry I don't know much about firebase storage.

chinalwb avatar Mar 19 '19 08:03 chinalwb