Retrieve Multiple Photos Under a Node from Firebase Storage

Retrieve multiple photos under a node from Firebase Storage

Currently there's no bulk or batched upload/download to/from Firebase Storage--I think there are too many question here: would we zip the files up and store them that way, would we returned a zipped bundle, etc. Would we just return an array of download URLs, or appropriate data?

Our solution to the problem of listing and downloading multiple files is to upload them individually and store the URLs in another database (say the Firebase Realtime Database), which you can then sync and use to download each file individually (or you store the download files and use a tool like SDWebImage to download or cache the appropriate URLs).

See https://www.youtube.com/watch?v=xAsvwy1-oxE&feature=youtu.be for an example of how we did this.

How to load multiple images from firebase storage in flutter?

A good solution could be store the urls on FireStore so you can query the url of th eimages you need and with a builder paint the images.

Upload multiple images to firebase storage

It is working fine.

 if (requestCode == Constants.REQUEST_CODE && resultCode == RESULT_OK) {
ArrayList<Image> images = data.getParcelableArrayListExtra(Constants.INTENT_EXTRA_IMAGES);
Uri[] uri=new Uri[images.size()];
for (int i =0 ; i < images.size(); i++) {
uri[i] = Uri.parse("file://"+images.get(i).path);
storageRef = storage.getReference("photos");
final StorageReference ref = storageRef.child(uri[i].getLastPathSegment());
ref.putFile(uri[i])
.addOnSuccessListener(this, new OnSuccessListener<UploadTask.TaskSnapshot>() {
public void onSuccess(UploadTask.TaskSnapshot taskSnapshot) {
Uri downloadUrl = taskSnapshot.getDownloadUrl();
String content = downloadUrl.toString();
if (content.length() > 0) {
editWriteMessage.setText("");
Message newMessage = new Message();
newMessage.text = content;
newMessage.idSender = StaticConfig.UID;
newMessage.idReceiver = roomId;
newMessage.timestamp = System.currentTimeMillis();
FirebaseDatabase.getInstance().getReference().child("message/" + roomId).push().setValue(newMessage);
}
}
});

}

}

How do I display all of the images from my Firebase Storage in React Native without needing image names?

As the documentation said about .listAll() here, you need to iterate through results :

const Photos = () => {
const [imageTab, setImageTab] = useState([]);

useEffect(() => {
firebase.storage()
.ref('VerifiedPhotos/')
.listAll()
.then(function(result) {
result.items.forEach(function(imageRef) {
imageRef.getDownloadURL().then(function(url) {
imageTab.push(url);
setImageTab(imageTab);
}).catch(function(error) {
// Handle any errors
});
});
})
.catch((e) => console.log('Errors while downloading => ', e));
}, []);

return (<View>
{imageTab.map(i => (<Image style={{height: 200, width: 200}} source={{uri: i}} />))}
</View>);
}

export default Photos;

Let me know if it worked :)

Get images from firebase storage and realtime database

you can save more than one image of specific user in images node like that.

DatabaseReference dr =  FirebaseDatabase.getInstance().getReference("tL131);

dr.child("images").push().setValue(String.ValueOf(taskSnapshot.getDownloadUrl()));

Firebase Storage - Upload multiple image files in Android

Currently, there's no available API to handle multiple file uploading or downloading from Firebase Storage.

Check the following workarounds:

  1. https://stackoverflow.com/a/37337436/6523173
  2. https://stackoverflow.com/a/37849978/6523173

Bulk import images into Firebase Storage and add download link to Firebase Database node

so after much research. best solution was to get storage somewhere else (i.e. Amazon S3), store there, and upload links to fb in proper node.



Related Topics



Leave a reply



Submit