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.")
})
}
}