¿Cómo subo imágenes a S3 en Swift?
puede consultar esta muestra:
https://github.com/awslabs/aws-sdk-ios-samples/tree/master/S3TransferUtility-Sample/Swift
Fragmentos y partes importantes de la muestra anterior:
Inicialización del SDK:
Copie esto en su info.plist:
Cargar código:
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; }