小编Abd*_*chi的帖子

将图像从UIImage Picker上传到新的Firebase(Swift)

我在我的应用程序中设置了UIImagePicker工作正常.当我的UIImage选择器被选中时,我想将个人资料图片上传到Firebase.这是我选择图片时的功能.

    //image picker did finish code
func imagePickerController(picker: UIImagePickerController, didFinishPickingMediaWithInfo info: [String : AnyObject]) {

    let chosenImage = info[UIImagePickerControllerOriginalImage] as! UIImage
    profilePic.contentMode = .ScaleAspectFill
    profilePic.image = chosenImage
    profilePic.hidden = false
    buttonStack.hidden = true
    changeButtonView.hidden = false
    self.statusLabel.text = "Here is Your Profile Picture"

    dismissViewControllerAnimated(true, completion: nil)


}
Run Code Online (Sandbox Code Playgroud)

新文档声明我们需要声明NSURl才能上传文件.这是我尝试找到给定文件的NSURL,但它不起作用.以下是文档及其链接:https://firebase.google.com/docs/storage/ios/upload-files#upload_from_data_in_memory

// File located on disk
let localFile: NSURL = ...
// Create a reference to the file you want to upload
let riversRef = storageRef.child("images/rivers.jpg")

// Upload the file …
Run Code Online (Sandbox Code Playgroud)

uiimagepickercontroller ios firebase swift2 firebase-storage

9
推荐指数
1
解决办法
2万
查看次数