我似乎无法使用当前代码将电影文件上传到Firebase存储。通过NSTemporaryDirectory将上传的视频文件保存到“ temp”目录时,我可以看到它们。电影文件也将显示为通过观察者上传,但我在Firebase存储中看不到它们。 有人能帮帮我吗?
let storageReference : StorageReference = {
return Storage.storage().reference(forURL: "gs://greenwealth-302e0.appspot.com/").child("myVideos")
}()
@IBAction func recordingBtn(_ sender: UIButton) {
if movieFileOutput.isRecording{
movieFileOutput.stopRecording()
//Upload video to firestorage
let udloadRef = storageReference.child("showMe.mov")
let uploadVideoTask = udloadRef.putFile(from: URL(fileURLWithPath: self.videoLocation()))
uploadVideoTask.observe(.progress) { (snapshot) in
print(snapshot.progress ?? "Progress cancelled")
}
uploadVideoTask.resume()
}
else{
//Start recoding
movieFileOutput.connection(with: .video)?.videoOrientation = self.videoOrientation()
movieFileOutput.maxRecordedDuration = maxRecordedDuration()
movieFileOutput.startRecording(to: URL(fileURLWithPath: self.videoLocation()), recordingDelegate: self)
}
}
func videoLocation() -> String{
let temporaryURL = NSTemporaryDirectory().appending("showMe.mov")
return temporaryURL
}