I have small bug in my program.
I have firebase Storage in my app. I wanna let the user to upload image to the storage.
the thing is when the user uploads image and then tries to upload another image. what the program does it overwrites the image was uploaded before.
what I want is to avoid "overwrite" when the user wants to upload another image. and keep both images in different file
let currentUser = Auth.auth().currentUser
let StorageRefrenece = Storage.storage().reference()
let posterImageRef =
StorageRefrenece.child("posters").child(currentUser!.uid).child("posterOne.jpg")
Thnx
The Files page provides an overview of the files contained in your Firebase Storage. This can be helpful for visualizing the structure of your Storage instance to verify that your application is working or if you need a convenient way to store just a few files like static images or video content for your application.
If the network connection is poor, the client is able to retry the operation right where it left off, saving your users time and bandwidth. Cloud Storage for Firebase stores your files in a Google Cloud Storage bucket, making them accessible through both Firebase and Google Cloud.
The Cloud Storage for Firebase SDK does not return object paths that contain two consecutive / s or end with a /.. For example, consider a bucket that has the following objects: The list operations on items in this bucket will give the following results:
Add firebase_storage, image_picker, path_provider, path and their versions to the dependencies section in your pubspec.yaml file: With the image_picker plugin, we have to do some extra setups for iOS and Android. Go to <your-project>/ios/Runner/Info.plist and add the following between <dict> and </dict>:
That is happening because you're storing them with the same name. In Firebase Storage you're the one in charge to decide the name of the files, there is no ".childByAutoId()
".
If you want to have different files, you can create random values to name them, that is well explained here: How does one generate a random number in Apple's Swift language?
Your final code should look like this:
StorageRefrenece.child("posters").child(currentUser!.uid).child(<#Any Random Value#>)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With