jeudi 7 juillet 2016

How to upload more than 1 image to AWS S3


As per title, how do I upload more than 1 image to AWS S3? I'm able to successfully upload 1 image into my AWS S3 bucket. However, my app allows users to upload up to three images, and is there a way not to specify the bucket, and AWSTransferManager again for three times? 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") }) }

1 commentaire: