swift - Obtain NSURL from UIImagePickerController -


i'm attempting grab file path of image selected through imagepickercontroller in order upload file firebase storage.

func imagepickercontroller(picker: uiimagepickercontroller, didfinishpickingmediawithinfo info: [string : anyobject]) {      mediauploadview.image = info[uiimagepickercontrolleroriginalimage] as? uiimage      let localurl: nsurl = (info[uiimagepickercontrollerreferenceurl] as! nsurl)     print(localurl)      let localfile: nsurl = localurl     let mediaref = storageref.child("media")      let uploadtask = mediaref.putfile(localurl, metadata: nil) { metadata, error in         if (error != nil) {         } else {             let downloadurl = metadata!.downloadurl         }     }       self.dismissviewcontrolleranimated(true, completion: nil)  } 

the output reads:

assets-library://asset/asset.jpg?id=c224da06-6b7b-4be2-8f5e-2ec7bc8b0526&ext=jpg body file unreachable: /asset.jpg error domain=nscocoaerrordomain code=4 "the file doesn’t exist." 

it grabs believe nsurl, unable find upload.

i have attempted follow along similar problem on stack "how image reference , upload image firebase?" output returns nil. great, thank you!

i had trouble getting info[uiimagepickercontrolleroriginalimage] work. had this:

let assets = phasset.fetchassetswithalasseturls([localurl], options: nil) let asset = assets.firstobject asset?.requestcontenteditinginputwithoptions(nil, completionhandler: { (contenteditinginput, info) in     let imagefile = contenteditinginput?.fullsizeimageurl     // call putfile imagefile instead of localurl