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:
- https://stackoverflow.com/a/37337436/6523173
- 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
Why Does Realitykit Memory Does Not Clear After Deinit Called
Xcode 6, Swift - Read Standard Input (Console) to String
Uialertview Is Crashing App on iOS 7
How to Find the Operator Definition in Swift
Swift - Get File Path of Currently Opened Document in Another Application
Swift - Force Synchronous Execution of Work and Subsequent UI Rendering
How to Trigger an Action When a Swiftui Toggle() Is Toggled
How to Save Document to "Files" App in Swift
Custom UI Tableviewcell Selected Backgroundcolor Swift
Swift, Sprite Kit Game: Have Circle Disappear in Clockwise Manner? on Timer
Detect Left and Right Click Events on Nsstatusitem (Swift)
Converting Swift 2.3 to Swift 3.0 - Error, Cannot Invoke 'Datatask' with an Argument List of Type'
A Switch Bug in Swift? - "Switch Must Be Exhaustive, Consider Adding a Default Clause."
Why Can't I Mutate a Variable Initially Set to a Certain Parameter When the Func Was Called
Uitextview Font to Always Be Fixed Size
How to Convert Anyclass to a Specific Class and Init It Dynamically in Swift