我有一个iOS应用程序可以上传/下载到Amazon的S3。我想用我自己的Minio云取代亚马逊的S3。
我遵循了https://github.com/minio/minio的快速教程,我在本地主机上运行了Minio,我可以使用s3cmd(https://docs.minio.io/docs/s3cmd-with-minio)来放置文件。
不幸的是,我无法在我的iOS应用程序中使用它。
我正在使用AWS SDK v2.4.16,因此我可以更改端点,并将其设置为localhost(http://my-imac.local:9000)并更新了我的访问权限和密钥,但我收到了SignatureDoesNotMatch错误:“请求我们计算的签名与您提供的签名不符。请检查您的密钥和签名方法。“。
指向我的本地服务器:
AWSEndpoint *minioEndpoint = [[AWSEndpoint alloc] initWithURLString:@"http://my-imac.local:9000"];
AWSServiceConfiguration *configuration = [[AWSServiceConfiguration alloc] initWithRegion:region
endpoint:minioEndpoint
credentialsProvider:credentialProvider];
[AWSS3 registerS3WithConfiguration:configuration forKey:s3RegionString];
这是我在本地主机上获得的内容:
time =“2017-04-10T23:36:21Z”level =错误 MSG = “{\” 方法\ “:\” PUT \” \ “路径\”:\ “/ mybucket / 28AB7D6DCFC44102955EBC0AEFF6E4E2-20170407161228839-0700 / foo_28AB7D6DCFC44102955EBC0AEFF6E4E2-20170407161228839-0700_v2.json_bin \”,\ “查询\”:\ “\” \ “头\”:{\ “接受\”:[\ “ / \”],\ “接受编码\”:[\“的gzip, 放气\ “] \” 接受语言\ “:\” EN-US \ “] \” 授权\ “:\” AWS4-HMAC-SHA256 凭据= LNTXV0YMMZ9SY7MD0ACZ / 20170410 /美东-1 / S3 / aws4_request, SignedHeaders =内容长度;内容类型;主机;用户代理; X-AMZ-日期, 签名= 7b2f4172dd926ba84c7edba5170028e0f9361bd8a656ad8f01c7e232f585ab31 \ “],\” 连接\ “:[\” 保持活动\ “],\” 内容长度\ “:[\” 282416 \ “],\” 内容类型\ “:[\”应用/八位字节流\ “],\” 主机\ “:[\” 我的-imac.local \ “],\” 用户代理\ “:[\” AWS-SDK-IOS / 2.4.16 iPhone-OS / 9.1 en_US \“],\”X-Amz-Date \“:[\”20170410T233620Z \“]}}” cause =“签名不匹配” 源= “[对象handlers.go:472:objectAPIHandlers.PutObjectHandler()]”
在iOS方面:
请求标头是:
{
Authorization = "AWS4-HMAC-SHA256 Credential=LNTXV0YMMZ9SY7MD0ACZ/20170410/us-east-1/s3/aws4_request, SignedHeaders=content-length;content-type;host;user-agent;x-amz-date, Signature=454c8bad35bdd3a15a08c9bf555fc69f1d5c0dabad78a474eabd4d844ca69aef";
"Content-Length" = 282416;
"Content-Type" = "application/octet-stream";
Host = "my-imac.local";
"User-Agent" = "aws-sdk-iOS/2.4.16 iPhone-OS/9.1 en_US";
"X-Amz-Date" = 20170410T233622Z;
}
回应:
2017-04-10 16:36:22.507 demo[7969:4711709] AWSiOSSDK v2.4.16 [Debug] AWSURLSessionManager.m line:566 | -[AWSURLSessionManager printHTTPHeadersForResponse:] | Response headers:
{
"Accept-Ranges" = bytes;
Connection = close;
"Content-Type" = "application/xml";
Date = "Mon, 10 Apr 2017 23:36:22 GMT";
Server = "Minio/RELEASE.2017-03-16T21-50-32Z (linux; amd64)";
"Transfer-Encoding" = Identity;
Vary = Origin;
"X-Amz-Request-Id" = 14B42D7AE5B09A2B;
}
答案 0 :(得分:0)
请替换ng-change
,accessKey
和secretKey
,根据您的需要更改地区,服务必须设为url
(如果您在.S3
中输入AWSS3
,xxxx:9000
会自动删除端口号,目前它只支持没有端口的完整网址,因此请确保您拥有端口9000的域映射,您可能需要参考此Setup Nginx proxy with Minio Server)
url
注意您还需要应用以下更改才能使其完全正常工作https://github.com/aws/aws-sdk-ios/pull/638