0

How do I get the myImage.png every time I upload to rename itself so it doesn't get replaced in the Firebase Storage?

    let storageRef = Storage.storage().reference().child("myImage.png")
    if let uploadData = UIImagePNGRepresentation(self.myImageView.image!){

        storageRef.putData(uploadData, metadata: nil, completion:
            {
                (metadata, error) in
                if error != nil {
                    print("error")
                    return
                }
Riccardo
  • 289
  • 1
  • 4
  • 22
  • You'll need to generate a unique filename. See https://stackoverflow.com/questions/37444685/store-files-with-unique-random-names – Frank van Puffelen Jun 23 '17 at 21:44
  • so should I do this?let storageRef = Storage.storage().reference().child("images/uuid/image.png ") – Riccardo Jun 23 '17 at 22:03
  • 1
    That is still a fixed path, so you will be writing to the same location each time. You will need to generate a path that is unique, e.g. `"images/\(NSUUID().UUIDString)/image.png"` – Frank van Puffelen Jun 23 '17 at 22:12

0 Answers0