ios - Saving & retrieving images on Firebase -


this question has answer here:

on process of trying firebase, possible replacement parse.com (unfortunately disappear), have saved png image online using code below, in swift.

    let fn = self.toolbox.getdocumentsdirectory().stringbyappendingpathcomponent("m0-1.png")     let im = uiimage(contentsoffile: fn),     dat = uiimagepngrepresentation(im!),     b64 = dat?.base64encodedstringwithoptions(.encoding64characterlinelength),     qs = ["string": b64!],     r = diltrootref.childbyappendingpath("zs"),     = ["img": qs]     r.setvalue(us) 

the saving part seems work, how suppose image saved? have tried far failed.

i recommend retrieving images using observesingleeventoftype(:_), because it's one-time read.

once have string value synchronized, can use nsdata() initializer, , create uiimage.

imageref.observesingleeventoftype(.value) { (imagesnap: fdatasnapshot!) in   let base64string = imagesnap.value as! string   let decodeddata = nsdata(base64encodedstring: base64string, options: nsdatabase64decodingoptions(rawvalue: 0))       let image = uiimage(data: decodeddata!) } 

check out example repo on using base64 images in uitableview.


Comments

Popular posts from this blog

sublimetext3 - what keyboard shortcut is to comment/uncomment for this script tag in sublime -

java - No use of nillable="0" in SOAP Webservice -

ubuntu - Laravel 5.2 quickstart guide gives Not Found Error -