How to store an array of images in Firebase Storage all under 1 path using iOS Swift -


i have 2 views, viewone , viewtwo.

inside viewone there 4 imageview outlets , postbutton. once user presses postbutton images sent firebase storage , there retrieved shown in viewtwo.

inside viewtwo there 4 imageview outlets receive images posted firebase storage viewone.

using firebase storage don't see anyway store multiple images inside storage under same path. understand how store 1 image per post storage , access it, not multiple images.

how post multiple images array in storage kept under 1 path(viewone)? how access of images(viewtwo)?

btw got awesome code (the custom function) viewtwo brian voong via youtube: https://youtu.be/b1vrjt7nvb0

this class image url strings go into. didn't bother putting init.

class imagedata: nsobject{ var imageoneurl: string? var imagetwourl: string? var imagethreeurl: string? var imagefoururl: string? } 

this imageviewone. didn't add in imagepicker delegates because seemed unnecessary how know how use them.

import firebase  imageviewone:uiviewcontroller, uiimagepickercontrollerdelegate, uinavigationcontrollerdelegate{  @iboutlet weak var imageviewone: uiimageview! @iboutlet weak var imageviewtwo: uiimageview! @iboutlet weak var imageviewthree: uiimageview! @iboutlet weak var imageviewfour: uiimageview!  var images = [imagedata]()  @ibaction func postbutton(sender: uibutton){  //unigue string images loaded under own path let uniqueimageidpath = nsuuid().uuidstring  //firebase storage ref let storageref = firstorage.storage().reference().child("images/\(uniqueimageidpath)")  //firebase image stored. need store images @ once. if let myimages = uiimagejpegrepresentation(self.imageviewone.image!, 0.1){      storageref.putdata(myimages, metadata: nil, completion: {                          (metadata, error) in                          if error != nil{                             print(error?.localizeddescription)                         }      if let myimagestring = metadata?.downloadurl()?.absolutestring{          let imagedata = imagedata()         imagedata.imageone = myimagestring         self.images.apped(imagedata)          let values = ["imageoneurl": imagedata.imageone, "imagetwo":"?", "imagethree":"?", "imagefour":"?"]          let ref = firdatabase.database().reference().child("users")         ref.updatechildvalues(values, withcompletionblock: {                  (error, user) in                  if error != nil{                     print(error?.localizeddescription)                 }             })         }     } } 

this viewtwo

import firebase  viewtwo: uiviewcontroller{  @iboutlet weak var imageviewone: uiimageview! @iboutlet weak var imageviewtwo: uiimageview! @iboutlet weak var imageviewthree: uiimageview! @iboutlet weak var imageviewfour: uiimageview!  var imageone: uiimage? var imagetwo: uiimage? var imagethree: uiimage? var imagefour: uiimage?  override func viewwillappear(animated: bool) {         super.viewwillappear(animated)      let ref = firdatabase.database().reference().child("users")      ref.observeeventtype(.childadded, withblock: {             (snapshot) in              if let dict = snapshot.value as? [string: anyobject]{             let imageurlstr = dict["imageoneurl"] as? string             self.loadimageusingcachewithurlstring(imageurlstr)     } }  //custom function func loadimageusingcachewithurlstring(urlstring: string){          let url = nsurl(string: urlstring)          nsurlsession.sharedsession().datataskwithurl(url!, completionhandler: {              (data, response, error) in              if error != nil {                 print(error?.localizeddescription)                 return             }              dispatch_async(dispatch_get_main_queue(), {                  if let displayimage = uiimage(data: data!){                      self.imageone = displayimage!                     self.imageviewone.image = self.imageone                 }              })          }).resume()     } } 

it turns firebase won't let store arrays of anything. after metadata url each image going have save each 1 individually inside fbdatabase , fbstorage.


Comments

Popular posts from this blog

mysql - Dreamhost PyCharm Django Python 3 Launching a Site -

java - Sending SMS with SMSLib and Web Services -

java - How to resolve The method toString() in the type Object is not applicable for the arguments (InputStream) -