0
我已經通過遵循AWS移動集線器集成頁面的指示,將swift 2.3中編寫的ios項目與AWS集成。在說明從s3存儲區下載文件的頁面中,它提供了一個函數,該函數使用AWSContent類型參數。我想使用該功能從S3存儲桶下載特定的文件。我嘗試使用AWSUserFileManager的contentWithKey成員與我的文件名和路徑,但得到「發現零,同時展開可選值」錯誤。任何人都可以指出我正確的方向嗎?謝謝。從S3存儲桶下載特定文件
private var manager: AWSUserFileManager!
class S3Access: NSObject {
func setupS3Acess() {
let x = manager.contentWithKey("public/GMG.csv")
downloadContent(x, pinOnCompletion: false)
}
// This code is from Amazon MobileHub integration page
private func downloadContent(content: AWSContent, pinOnCompletion: Bool) {
content.downloadWithDownloadType(
.IfNewerExists,
pinOnCompletion: pinOnCompletion,
progressBlock: {[weak self](content: AWSContent?, progress: NSProgress?) -> Void in
guard self != nil else { return }
/* Show progress in UI. */
},
completionHandler: {[weak self](content: AWSContent?, data: NSData?, error: NSError?) -> Void in
guard self != nil else { return }
if let error = error {
print("Failed to download a content from a server. \(error)")
return
}
print("Object download complete.")
})
}
}