我正在开发将截图上传到macOS应用程序的存储。我在下面使用了这些代码,它不会引发任何错误或崩溃。上传和在putFile上进行回调后,我看不到存储上的任何新文件。
let storage = Storage.storage()
let localFile = URL(string: "/Users/truonghieu/Library/Containers/com.example.appname/Data/Documents/appname/image.jpg")
let storageRef = storage.reference().child("abc.jpg")
let uploadTask = storageRef.putFile(from: localFile!, metadata: nil) { metadata, error in
guard metadata != nil else{
print("error: \(String(describing: error?.localizedDescription))")
return
}
let fileManager = FileManager.default
if fileManager.fileExists(atPath: localPath) {
do {
try fileManager.removeItem(at: localFile!)
print("success: move item\(localPath)")
}catch{
print("failed: move item\(localPath)")
}
}
}
我正在使用:
Xcode version: 10
Firebase SDK version: Newest from Git
Firebase Component: Storage, Auth, Core
Component version: Newest from branch master