我正在使用iOS AWS SDK在Mac应用上将文件上传到Amazon S3。
它适用于大多数语言(英语,法语,德语等),但在测试日语,中文和其他语言的本地化时失败。这是我在使用其中一个本地化时遇到的错误:
Failed with error: Error Domain=com.amazonaws.AWSGeneralErrorDomain Code=3 "未能完成该操作。(com.amazonaws.AWSGeneralErrorDomain 错误 3。)" UserInfo=0x6000001bcfc0 {SignatureProvided=534652dd131bdab6bec073d4cf62a21abf877763b1012818083c3b72b4229383, CanonicalRequest=PUT
content-encoding:aws-chunked
content-type:binary/octet-stream
host:s3.amazonaws.com
transfer-encoding:Chunked
user-agent:aws-sdk-iOS/2.0.8 OSX/
x-amz-acl:public-read-write
x-amz-content-sha256:STREAMING-AWS4-HMAC-SHA256-PAYLOAD
x-amz-date:20150708T042622Z
x-amz-decoded-content-length:16440
x-amz-server-side-encryption:AES256
content-encoding;content-type;host;transfer-encoding;user-agent;x-amz-acl;x-amz-content-sha256;x-amz-date;x-amz-decoded-content-length;x-amz-server-side-encryption
STREAMING-AWS4-HMAC-SHA256-PAYLOAD, StringToSign=AWS4-HMAC-SHA256
20150708T042622Z
20150708/us-east-1/s3/aws4_request
c3152a63369748f3f0f0cc67de584a1c2a87637270e750714779f4d54fb38b32, Code=SignatureDoesNotMatch, RequestId=D5166A20DF835DAE, HostId=FPPpmVOnpuYpnnEkGn4Qph0jSzNeE3qxLXmtkQI3tSrZcGDNGYJCArXc5T9xKcUy, StringToSignBytes=41 57 53 34 2d 48 4d 41 43 2d 53 48 41 32 35 36 0a 32 30 31 35 30 37 30 38 54 30 34 32 36 32 32 5a 0a 32 30 31 35 30 37 30 38 2f 75 73 2d 65 61 73 74 2d 31 2f 73 33 2f 61 77 73 34 5f 72 65 71 75 65 73 74 0a 63 33 31 35 32 61 36 33 33 36 39 37 34 38 66 33 66 30 66 30 63 63 36 37 64 65 35 38 34 61 31 63 32 61 38 37 36 33 37 32 37 30 65 37 35 30 37 31 34 37 37 39 66 34 64 35 34 66 62 33 38 62 33 32, AWSAccessKeyId=<REMOVEDFORSTACKOVERFLOW>, CanonicalRequestBytes=50 55 54 0a 2f 69 6f 73 6d 61 63 74 68 65 66 69 6c 65 63 6f 6e 76 65 72 74 65 72 31 30 2f 6d 68 65 72 72 61 62 68 7a 7a 2e 70 64 66 0a 0a 63 6f 6e 74 65 6e 74 2d 65 6e 63 6f 64 69 6e 67 3a 61 77 73 2d 63 68 75 6e 6b 65 64 0a 63 6f 6e 74 65 6e 74 2d 74 79 70 65 3a 62 69 6e 61 72 79 2f 6f 63 74 65 74 2d 73 74 72 65 61 6d 0a 68 6f 73 74 3a 73 33 2e 61 6d 61 7a 6f 6e 61 77 73 2e 63 6f 6d 0a 74 72 61 6e 73 66 65 72 2d 65 6e 63 6f 64 69 6e 67 3a 43 68 75 6e 6b 65 64 0a 75 73 65 72 2d 61 67 65 6e 74 3a 61 77 73 2d 73 64 6b 2d 69 4f 53 2f 32 2e 30 2e 38 20 4f 53 58 2f 0a 78 2d 61 6d 7a 2d 61 63 6c 3a 70 75 62 6c 69 63 2d 72 65 61 64 2d 77 72 69 74 65 0a 78 2d 61 6d 7a 2d 63 6f 6e 74 65 6e 74 2d 73 68 61 32 35 36 3a 53 54 52 45 41 4d 49 4e 47 2d 41 57 53 34 2d 48 4d 41 43 2d 53 48 41 32 35 36 2d 50 41 59 4c 4f 41 44 0a 78 2d 61 6d 7a 2d 64 61 74 65 3a 32 30 31 35 30 37 30 38 54 30 34 32 36 32 32 5a 0a 78 2d 61 6d 7a 2d 64 65 63 6f 64 65 64 2d 63 6f 6e 74 65 6e 74 2d 6c 65 6e 67 74 68 3a 31 36 34 34 30 0a 78 2d 61 6d 7a 2d 73 65 72 76 65 72 2d 73 69 64 65 2d 65 6e 63 72 79 70 74 69 6f 6e 3a 41 45 53 32 35 36 0a 0a 63 6f 6e 74 65 6e 74 2d 65 6e 63 6f 64 69 6e 67 3b 63 6f 6e 74 65 6e 74 2d 74 79 70 65 3b 68 6f 73 74 3b 74 72 61 6e 73 66 65 72 2d 65 6e 63 6f 64 69 6e 67 3b 75 73 65 72 2d 61 67 65 6e 74 3b 78 2d 61 6d 7a 2d 61 63 6c 3b 78 2d 61 6d 7a 2d 63 6f 6e 74 65 6e 74 2d 73 68 61 32 35 36 3b 78 2d 61 6d 7a 2d 64 61 74 65 3b 78 2d 61 6d 7a 2d 64 65 63 6f 64 65 64 2d 63 6f 6e 74 65 6e 74 2d 6c 65 6e 67 74 68 3b 78 2d 61 6d 7a 2d 73 65 72 76 65 72 2d 73 69 64 65 2d 65 6e 63 72 79 70 74 69 6f 6e 0a 53 54 52 45 41 4d 49 4e 47 2d 41 57 53 34 2d 48 4d 41 43 2d 53 48 41 32 35 36 2d 50 41 59 4c 4f 41 44, Message=The request signature we calculated does not match the signature you provided. Check your key and signing method.}
我的代码适用于英语和我尝试过的任何欧洲语言,这里是:
AWSStaticCredentialsProvider *credentialsProvider = [AWSStaticCredentialsProvider credentialsWithAccessKey:ACCESS_KEY_ID secretKey:SECRET_KEY];
configuration = [AWSServiceConfiguration configurationWithRegion:AWSRegionUSEast1 credentialsProvider:credentialsProvider];
[AWSServiceManager defaultServiceManager].defaultServiceConfiguration = configuration;
_transferManager = [AWSS3TransferManager defaultS3TransferManager];
AWSS3TransferManagerUploadRequest *uploadRequest = [AWSS3TransferManagerUploadRequest new];
uploadRequest.bucket = BUCKET_NAME;
uploadRequest.key = file.amazonKey;
uploadRequest.body = [NSURL URLWithString:file.ogFilePath];
uploadRequest.ACL = uploadRequest.ACL=AWSS3BucketCannedACLPublicReadWrite;
uploadRequest.serverSideEncryption = AWSS3ServerSideEncryptionAES256;
[[_transferManager upload:uploadRequest] continueWithExecutor:[BFExecutor mainThreadExecutor]
withBlock:^id(BFTask *task) {