问题
When running the AWSiOSDemoTVM project, the async S3 demo code will start uploading data, but the connection will be dropped after a couple of seconds.
AWSiOSDemoTVM: didFailWithError : Error Domain=NSURLErrorDomain Code=-1005 "The network connection was lost."UserInfo=0xb54e850 {NSErrorFailingURLStringKey=https://BUCKETNAME.s3.amazonaws.com/asyncDemoKey, NSErrorFailingURLKey=https://BUCKETNAME.s3.amazonaws.com/asyncDemoKey, NSLocalizedDescription=The network connection was lost., NSUnderlyingError=0xb5527f0 "The network connection was lost."}
Small uploads without using the asynchronous delegate will succeed.
回答1:
I didn't set the correct endpoint for the bucket. The default endpoint only works for US buckets.
In AmazonClientManager.m, add the correct endpoint for your bucket region.
s3 = [[AmazonS3Client alloc] initWithCredentials:credentials];
s3.endpoint = @"https://s3-eu-west-1.amazonaws.com";
A list of regional endpoints for S3 and other AWS services can be found here
来源:https://stackoverflow.com/questions/10971707/amazon-aws-s3-sdk-for-ios-drops-connection-error-1005