当我尝试按照文档中的示例从 Firebase 存储中存储文件时,我收到以下错误:
Optional(Error Domain=FIRStorageErrorDomain Code=-13000 "发生未知错误,请检查服务器响应。" UserInfo={object=ProfilePicture/Jf2dFzI7LZNzQkOkdFfa3UWQJyH2.jpg, bucket=mapit-1333.appspot.com, NSLocalizedDescription=发生未知错误, 请检查服务器响应。, ResponseErrorDomain=NSCocoaErrorDomain, NSFilePath=/local/images, NSUnderlyingError=0x7fc8a080ab50 {Error Domain=NSPOSIXErrorDomain Code=13 "Permission denied"}, ResponseErrorCode=513})
这是我的代码:
let storage = FIRStorage.storage()
let storageRef = storage.referenceForURL("gs://mapit-1333.appspot.com")
let islandRef = storageRef.child("ProfilePicture/"+uid+".jpg")
// Create local filesystem URL
let localURL: NSURL! = NSURL(string: "file:///local/images/island.jpg")
// Download to the local filesystem
let downloadTask = islandRef.writeToFile(localURL) { (URL, error) -> Void in
if (error != nil) {
print(error)
} else {
let data = NSData(contentsOfURL: URL!)
self.profileImage.image = UIImage(data: data!)
}
}