i'm trying send user image ios app python script through firebase creating base64 string image , posting string firebase , decoding in python. however, corrupted image produced. how fix this? here swift code:
func imagepickercontroller(picker: uiimagepickercontroller, didfinishpickingmediawithinfo info: [string : anyobject]) { var bytearray = nsdata() if let file = info[uiimagepickercontrolleroriginalimage] as? uiimage { bytearray = uiimagejpegrepresentation(file, 1.0)! } let b64 = bytearray.base64encodedstringwithoptions(nsdatabase64encodingoptions(rawvalue: 0)) firdatabase.database().reference().child("datauploaded").setvalue(b64) uploaded = true dismissviewcontrolleranimated(true, completion: nil) }
and python code:
from firebase import firebase import os pil import image import numpy np import io fb = firebase.firebaseapplication("https://xxxxxx.firebaseio.com/", none) = fb.get('/datauploaded', none) filename = 'image.png' open(filename, 'wb') f: f.write(a)
Comments
Post a Comment