1. 程式人生 > 其它 >亞馬遜 IOS sts s3上傳

亞馬遜 IOS sts s3上傳

 1 // aws oss
 2 AWSBasicSessionCredentialsProvider *credentialsProvider = [[AWSBasicSessionCredentialsProvider alloc] initWithAccessKey:accessKeyId
 3                                                                                                              secretKey:accessKeySecret
 4                                                                                                           sessionToken:securityToken];
5 AWSServiceConfiguration *configuration = [[AWSServiceConfiguration alloc] initWithRegion:AWSRegionAPSoutheast1 6 credentialsProvider:credentialsProvider]; 7 [AWSServiceManager defaultServiceManager].defaultServiceConfiguration = configuration;
8 9 AWSS3TransferUtilityUploadExpression *profileImageUploadExpression = [AWSS3TransferUtilityUploadExpression new]; 10 [profileImageUploadExpression setValue:@"public-read-write" forRequestParameter:@"x-amz-acl"]; 11 12 AWSS3TransferUtility *transferUtility = [AWSS3TransferUtility defaultS3TransferUtility];
13 [transferUtility uploadData:data 14 bucket:bucketName 15 key:filePath 16 contentType:@"image/jpeg" 17 expression:profileImageUploadExpression 18 completionHandler: ^(AWSS3TransferUtilityUploadTask *task, NSError *error) { 19 20 }]; 21 }];
學習時的痛苦是暫時的 未學到的痛苦是終生的