且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何从特定用户获取Firebase中的所有图片网址

更新时间:2023-11-27 21:13:34

在客户端没有列出Firebase存储项目的API。


I am adding images for all user in storage section, below is my code for uploading images.

public void uploadImage(byte[] data, final String fileName) {
    mProgressDialog.setMessage("Uploading image....");
    mProgressDialog.show();

    StorageReference filepath=mStorageRef.child("Photos").child(fileName);
    filepath.putBytes(data).addOnSuccessListener(new OnSuccessListener<UploadTask.TaskSnapshot>() {

        @Override
        public void onSuccess(UploadTask.TaskSnapshot taskSnapshot) {
            mProgressDialog.dismiss();
            String mUrl=taskSnapshot.getDownloadUrl().toString();

            // got url for this image what to do with this url.....
            Toast.makeText(MainActivity1.this,"Upload done!",Toast.LENGTH_LONG).show();
        }

    });
}

I want to obtain all images url stored for a particular user.

There is no API for listing items of Firebase Storage on the client side.

You should modify your file upload method to also store that download URL somewhere in the user's control, like a user-specific path in the Realtime Database.