我正在尝试设置一个S3来存储我的iOS客户端的配置文件图像。我有它的工作,但我在国家另一边的我的伙伴无法上传所以搞乱了,现在我也无法上传。我仍然可以下载那里的图像,但仅此而已。
以下是我用来上传它们的代码:
let credentialsProvider = AWSCognitoCredentialsProvider(regionType:.USWest2, identityPoolId: myIdentityPoolId)
let configuration = AWSServiceConfiguration(region:.USWest2, credentialsProvider:credentialsProvider)
AWSServiceManager.defaultServiceManager().defaultServiceConfiguration = configuration
let uploadRequest = AWSS3TransferManagerUploadRequest()
uploadRequest.body = generateImageUrl(remoteName, image: image)
uploadRequest.key = remoteName
uploadRequest.bucket = S3BucketName
uploadRequest.contentType = "image/jpeg"
let transferManager = AWSS3TransferManager.defaultS3TransferManager()
// Perform file upload
transferManager.upload(uploadRequest).continueWith(executor: AWSExecutor.mainThreadExecutor(), block: { (task:AWSTask) -> AnyObject? in
if let error = task.error {
if error.domain == AWSS3TransferManagerErrorDomain, let code = AWSS3TransferManagerErrorType(rawValue: error.code) {
switch code {
case .Cancelled, .Paused:
break
default:
print("Error uploading: \(uploadRequest.key)")
}
} else {
print("Error uploading: \(uploadRequest.key)")
}
return nil
}
let uploadOutput = task.result
print("Upload complete for: \(uploadRequest.key)")
return nil
我收到了这些错误:
2017-03-08 ... [] nw_endpoint_flow_prepare_output_frames [10.1 52.218.128.128:443 ready socket-flow (satisfied)] Failed to use 1 frames, marking as failed
2017-03-08 ... [] nw_endpoint_handler_add_write_request [10.1 52.218.128.128:443 failed socket-flow (satisfied)] cannot accept write requests
2017-03-08 ... [] __tcp_connection_write_eof_block_invoke Write close callback received error: [22] Invalid argument
2017-03-08 ... AWSiOSSDK v2.5.1 [Error] AWSURLSessionManager.m line:212 | -[AWSURLSessionManager URLSession:task:didCompleteWithError:] | Session task failed with error: Error Domain=NSURLErrorDomain Code=-1001 "The request timed out." UserInfo={NSUnderlyingError=0x17005c560 {Error Domain=kCFErrorDomainCFNetwork Code=-1001 "(null)" UserInfo={_kCFStreamErrorCodeKey=-2102, _kCFStreamErrorDomainKey=4}}, NSErrorFailingURLStringKey=<myUrl>, NSErrorFailingURLKey=<myUrl>, _kCFStreamErrorDomainKey=4, _kCFStreamErrorCodeKey=-2102, NSLocalizedDescription=The request timed out.}
任何指针都会非常感激。这是我第一次使用S3而且我还是很迷茫。提前谢谢!
答案 0 :(得分:0)
解决:事实证明我的朋友有一个不同版本的豆荚,当我拉他的版本时,我也得到了过时的版本。在我们找到解决方案pod update
之前,我们挣扎了大约一周。
TL / DR:pod update