How would I store a video into firebase storage from swift?

大憨熊 提交于 2019-12-22 01:09:49

问题


I'm trying to select a video from a users camera roll which I have done now I"m not sure how to save it to the firebase storage system, how would I got about doing that?


回答1:


1) Create a reference to your storage

2) Upload your file. (It can be video or audio or images)

import FirebaseStorage
var storage = FIRStorage.storage()
var storageRef = storage.reference(forURL: "gs://xyz.appspot.com")

let uploadTask = storageRef.putFile(from: localFile, metadata: nil) { metadata, error in
  if let error = error 
  {
    //do error handle
  } 
}

The document from Firebase also explains nicely on how to upload and download contents from firebase storage.



来源:https://stackoverflow.com/questions/44170797/how-would-i-store-a-video-into-firebase-storage-from-swift

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!