问题描述
我正在尝试从 Firebase Storage 下载视频并将其本地存储到我的设备中,如下所示,但出现错误 An unkNown error occurred,please check the server response.
当这看起来类似于 Firebase 的 documentation
时,我不知道我做错了什么这是我的代码
let videoRef = storage.reference(forURL: "https://firebasestorage.googleapis.com/v0/b/bolar-ea96c.appspot.com/o/ChatVideos%2FL1f4FHqRlMYRJvUxP31c7FwI7Wj2:eUuKNzOByBcjQbwAZXmzY4iPj952%2F98E983A0-0E91-4DAB-BF50-16C1AF2E1894%2FIMG_4776.MOV?alt=media&token=1867f82e-e24e-43b9-99ad-5d21163f1469")
let paths = NSSearchPathForDirectoriesInDomains(.downloadsDirectory,.userDomainMask,true)
let documentsDirectory = paths[0]
let docURL = URL(string: documentsDirectory)!
let localUrl = docURL.appendingPathComponent("\(self.chatRoomId)/\(chatId)")
if !FileManager.default.fileExists(atPath: localUrl.absoluteString) {
do {
let downloadTask = videoRef.write(toFile: localUrl) { (videoLocalUrl,error) in //download the video from Storage and store it to a localUrl
if let error = error {
print("Error getting video URL from \(videoUrl.absoluteString) \nWith error = \(error.localizedDescription)")
return //MARK: Getting error here
}
chat.video?.videoLocalUrl = videoLocalUrl!
tempChats.append(chat)
print("Successfully downloaded video from \(videoLocalUrl!)")
}
downloadTask.observe(.success) { (snapshot) in
print("Completed \(snapshot)")
}
}
}
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)