亞馬遜 IOS sts s3上傳
阿新 • • 發佈:2022-02-10
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 }];