osx无法将文件上传到存储。没有调用uploadTask.putFile回调

时间:2018-09-29 07:20:37

标签: swift macos firebase

我正在开发将截图上传到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

0 个答案:

没有答案