简体   繁体   English

在android中添加图片到firebase?

[英]Adding images to firebase in android?

I am able to get uID of current user in Firebase.我能够在 Firebase 中获取当前用户的 uID。

i am saving name and url of the image in firebase database.我正在将图像的名称和 url 保存在 firebase 数据库中。

I want to save all the image url and name of the image of current user under only 1 node that is its uID.我想将所有图像 url 和当前用户的图像名称保存在仅 1 个节点下,即它的 uID。

fileReference.getDownloadUrl().addOnSuccessListener(new OnSuccessListener<Uri>() {
    @Override
    public void onSuccess(Uri uri)
    {
        //Do what you want with the url
        Upload upload = new Upload(filename,
                fileURL);
        mDatabaseRef.child(currentFirebaseUser.getUid()).setValue(upload);
        Toast.makeText(MainActivity.this, "Upload successful", Toast.LENGTH_LONG).show();
    }
});

Whenever you want to make a list under a certain node, call push() to generate a unique location.每当你想在某个节点下创建一个列表时,调用push()来生成一个唯一的位置。 So in your case that'd be:所以在你的情况下是:

mDatabaseRef.child(currentFirebaseUser.getUid()).push().setValue(upload);

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM