gpt4 book ai didi

ios - 错误 : The request signature we calculated does not match the signature you provided. 检查您的 key 和签名方法

转载 作者:塔克拉玛干 更新时间:2023-11-02 08:15:58 25 4
gpt4 key购买 nike

我正在尝试在 iOS 上执行 AWS 上传。我正在遍历一组 AWSS3TransferManagerUploadRequest 对象,并将大量不同大小的图像 (1000+) 上传到 S3 存储桶。使用:

AWSS3TransferManager *transferManager = [AWSS3TransferManager defaultS3TransferManager];

[[transferManager upload:request] continueWithExecutor:[BFExecutor mainThreadExecutor]
withBlock:^id(BFTask *task) {

一旦我到达大约第 700 张图片,上传进度开始变得非常缓慢,然后我开始在随后的所有其他图片上传中收到这些错误:

2015-03-27 11:07:30.238 crafted[4979:1414229] Error: Error Domain=com.amazonaws.AWSGeneralErrorDomain Code=3 "The operation couldn’t be completed. (com.amazonaws.AWSGeneralErrorDomain error 3.)" UserInfo=0x1709b5b60 {SignatureProvided=f8c21dd55c323378b05c660a5f27255a2aecbd6eee1f2ca0c5fb0460136dde30, RequestId=DB37767F9C1AFD7E, StringToSign=AWS4-HMAC-SHA256-PAYLOAD
20150327T160658Z
20150327/us-west-2/s3/aws4_request
1e63d8ac434ee08f333a4f59c52fc3565e5b451cca9c7f1a946e209fb72f24c5
e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855
11b7db18ee4cbdedc46907daa5e99688b2be72da3a943ac0354a9405b7c59f19, Code=SignatureDoesNotMatch, HostId=0V4bjdhjCG/wt/NAlsgr1K7DV6QkUdYOlwjFRfmBI/swFesufXVi19PTgacwOBt1, StringToSignBytes=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 32 30 31 35 30 33 32 37 54 31 36 30 36 35 38 5a 0a 32 30 31 35 30 33 32 37 2f 75 73 2d 77 65 73 74 2d 32 2f 73 33 2f 61 77 73 34 5f 72 65 71 75 65 73 74 0a 31 65 36 33 64 38 61 63 34 33 34 65 65 30 38 66 33 33 33 61 34 66 35 39 63 35 32 66 63 33 35 36 35 65 35 62 34 35 31 63 63 61 39 63 37 66 31 61 39 34 36 65 32 30 39 66 62 37 32 66 32 34 63 35 0a 65 33 62 30 63 34 34 32 39 38 66 63 31 63 31 34 39 61 66 62 66 34 63 38 39 39 36 66 62 39 32 34 32 37 61 65 34 31 65 34 36 34 39 62 39 33 34 63 61 34 39 35 39 39 31 62 37 38 35 32 62 38 35 35 0a 31 31 62 37 64 62 31 38 65 65 34 63 62 64 65 64 63 34 36 39 30 37 64 61 61 35 65 39 39 36 38 38 62 32 62 65 37 32 64 61 33 61 39 34 33 61 63 30 33 35 34 61 39 34 30 35 62 37 63 35 39 66 31 39,

AWSAccessKeyId=ASIAJCSIGUTUKG2HSYCA,
Message=The request signature we calculated does not match the signature you provided. Check your key and signing method.}

“我们计算出的请求签名与您提供的签名不匹配。请检查您的 key 和签名方法。”

我不知道为什么会这样,也找不到关于此问题的类似问答。

编辑:我正在使用 Cognito Identity 池进行身份验证并提供对 s3 存储桶的匿名访问权限,仅用于放置。

编辑 2:根据 Yosuke 的请求编写代码(我只是构建了一个请求对象数组,然后遍历该数组并上传每个请求):

- (void)performS3UploadWithRequest:(NSMutableArray *)requests
{
for (AWSS3TransferManagerUploadRequest *request in requests) {

AWSS3TransferManager *transferManager = [AWSS3TransferManager defaultS3TransferManager];

__weak typeof(self) weakSelf = self;
[[transferManager upload:request] continueWithExecutor:[BFExecutor mainThreadExecutor]
withBlock:^id(BFTask *task) {
if (task.error) {
if ([task.error.domain isEqualToString:AWSS3TransferManagerErrorDomain]) {
switch (task.error.code) {
case AWSS3TransferManagerErrorCancelled:
case AWSS3TransferManagerErrorPaused:
break;

default:
NSLog(@"Error: %@", task.error);
break;

}
} else {
// Unknown error.
NSLog(@"Error: %@", task.error);
}
}

if (task.result) {
AWSS3TransferManagerUploadOutput *uploadOutput = task.result;

// The file uploaded successfully.
NSLog(@"%@", uploadOutput);
[weakSelf countUploadProgress];
}
return nil;
}];
}
}

- (AWSS3TransferManagerUploadRequest *)createUploadRequestWithDestinationBucket:(NSString *)destBucket Key:(NSString *)key Body:(NSURL *)body
{
AWSS3TransferManagerUploadRequest *uploadRequest = [AWSS3TransferManagerUploadRequest new];
uploadRequest.bucket = destBucket;
uploadRequest.key = key;
uploadRequest.body = body;
uploadRequest.contentType = @"binary/octet-stream";

uploadRequest.uploadProgress = ^(int64_t bytesSent, int64_t totalBytesSent, int64_t totalBytesExpectedToSend) {
dispatch_async(dispatch_get_main_queue(), ^{
if (totalBytesExpectedToSend > 0) {
NSLog(@"%f", (float)((double) totalBytesSent / totalBytesExpectedToSend));
}
});
};

return uploadRequest;
}

最佳答案

感谢 Yosuke,我找到了一个 solution这是按顺序运行 for 循环。它有点慢,但没有问题,即使上传 1000 多张照片仍然很快。

- (void)performS3UploadWithRequest:(NSMutableArray *)requests
{
AWSS3TransferManager *transferManager = [AWSS3TransferManager defaultS3TransferManager];

BFTask *task = [BFTask taskWithResult:nil];

__weak typeof(self) weakSelf = self;
for (AWSS3TransferManagerUploadRequest *request in requests) {
task = [task continueWithSuccessBlock:^id(BFTask *task) {
return [[transferManager upload:request] continueWithExecutor:[BFExecutor mainThreadExecutor]
withBlock:^id(BFTask *task) {
if (task.error) {
if ([task.error.domain isEqualToString:AWSS3TransferManagerErrorDomain]) {
switch (task.error.code) {
case AWSS3TransferManagerErrorCancelled:
case AWSS3TransferManagerErrorPaused:
break;

default:
NSLog(@"Error: %@", task.error);
break;

}
} else {
// Unknown error.
NSLog(@"Error: %@", task.error);
}
}

if (task.result) {
AWSS3TransferManagerUploadOutput *uploadOutput = task.result;
[weakSelf countUploadProgress];

// The file uploaded successfully.
NSLog(@"%@", uploadOutput);
}
return nil;
}];

}];

[task continueWithSuccessBlock:^id(BFTask *task) {
return nil;
}];
}

}

关于ios - 错误 : The request signature we calculated does not match the signature you provided. 检查您的 key 和签名方法,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29305474/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com