How do I upload images to S3 in Swift?
you can refer to this sample:
https://github.com/awslabs/aws-sdk-ios-samples/tree/master/S3TransferUtility-Sample/Swift
Snippets and important parts from the above sample:
SDK initialization:
Copy this into your info.plist:
Upload Code :
let transferUtility = AWSS3TransferUtility.default()
let expression = AWSS3TransferUtilityUploadExpression()
expression.progressBlock = progressBlock
transferUtility.uploadData(
data,
bucket: S3BucketName,
key: S3UploadKeyName,
contentType: "image/png",
expression: expression,
completionHandler: completionHandler).continueWith { (task) -> AnyObject! in
if let error = task.error {
print("Error: \(error.localizedDescription)")
self.statusLabel.text = "Failed"
}
if let _ = task.result {
self.statusLabel.text = "Generating Upload File"
print("Upload Starting!")
// Do something with uploadTask.
}
return nil;
}