如何将超过1个图像上载到AWS S3

时间:2016-06-23 02:01:39

标签: ios swift amazon-web-services amazon-s3

根据标题,如何将超过1张图像上传到AWS S3?我能够将1张图片成功上传到我的AWS S3存储桶中。但是,我的应用程序允许用户上传最多三张图片,有没有办法不指定存储桶,并且AWSTransferManager再次三次?

let uploadRequest: AWSS3TransferManagerUploadRequest = AWSS3TransferManagerUploadRequest()
uploadRequest.bucket = "mybucket"
uploadRequest.ACL = AWSS3ObjectCannedACL.PublicRead
uploadRequest.key = "media/uploads"
uploadRequest.contentType = "image/png"
uploadRequest.body = url

let transferManager: AWSS3TransferManager = AWSS3TransferManager.defaultS3TransferManager()

transferManager.upload(uploadRequest).continueWithExecutor(AWSExecutor.mainThreadExecutor(), withBlock: {(task: AWSTask) -> AnyObject! in
     if task.error != nil {
          print(task.error)
          NSLog("Error uploading : " + uploadRequest.key!)
     }
     else {
          NSLog("Upload completed")
     })
}

0 个答案:

没有答案