S3停止在iOS上上传文件

S3停止在iOS上上传文件,ios,swift,amazon-web-services,amazon-s3,Ios,Swift,Amazon Web Services,Amazon S3,我有两个应用程序,一个在swift中,另一个在objective-c中,我正在使用cognito对s3进行身份验证,但最近这项功能停止工作,我知道原因,我的应用程序的控制台显示“请求超时”,但我没有更改任何内容。应用程序开始上载,但总是在39%或14%时停止并冻结上载,这是我的代码: 应用程序代表: let credentialsProvider = AWSCognitoCredentialsProvider(regionType:.USEast1, identityPo

我有两个应用程序,一个在swift中,另一个在objective-c中,我正在使用cognito对s3进行身份验证,但最近这项功能停止工作,我知道原因,我的应用程序的控制台显示“请求超时”,但我没有更改任何内容。应用程序开始上载,但总是在39%或14%时停止并冻结上载,这是我的代码:

应用程序代表:

    let credentialsProvider = AWSCognitoCredentialsProvider(regionType:.USEast1,
        identityPoolId:poolId)
    AWSLogger.defaultLogger().logLevel = .Verbose

    let configuration = AWSServiceConfiguration(region:.SAEast1, credentialsProvider:credentialsProvider)

    AWSServiceManager.defaultServiceManager().defaultServiceConfiguration = configuration
光电控制器

 let uploadRequest = AWSS3TransferManagerUploadRequest()
 uploadRequest.bucket = "bucket"
 uploadRequest.ACL = AWSS3ObjectCannedACL.PublicRead
 uploadRequest.key = "\(self.userLogin.customer_subdomain)/photos/\(imageName)"
 uploadRequest.contentType = "image/png"
 uploadRequest.body = url

 uploadRequest.uploadProgress = { (bytesSent:Int64, totalBytesSent:Int64,  totalBytesExpectedToSend:Int64) -> Void in
     dispatch_sync(dispatch_get_main_queue(), {() -> Void in
         self.updateLabel(totalBytesSent,totalBytesExpectedToSend: totalBytesExpectedToSend)
     })
 }

 AWSS3TransferManager.defaultS3TransferManager().upload(uploadRequest).continueWithBlock { (task) -> AnyObject! in
     if (task.error != nil) {
         //failed
         dispatch_async(dispatch_get_main_queue()) {
                        self.dismissViewControllerAnimated(false, completion: nil)
             let refreshAlert = UIAlertController(title: "Error", message: "Error al intentar subir el archivo", preferredStyle: UIAlertControllerStyle.Alert)
             refreshAlert.addAction(UIAlertAction(title: "OK", style: .Default, handler: nil))
             self.presentViewController(refreshAlert, animated: true, completion: nil)
         }
         print(task.error!)
     } else {
         let dic=["file":"\(self.userLogin.customer_subdomain)/photos/\(imageName)"]
         let jsonData = try! NSJSONSerialization.dataWithJSONObject(dic, options: [])
         let jsonString = NSString(data: jsonData, encoding: NSUTF8StringEncoding)! as String

         let con:URLConnection
         con=URLConnection.init()
         con.delegate=self
         let headers=["X-Auth-Token":self.userLogin.api_token]
         con.connect(self.userLogin.customer_url+"/rest/activities/\(self.activity.id)/photos",method:"POST",json: jsonString, headers: headers)
         self.imgName = "\(self.userLogin.customer_subdomain)/photos/\(imageName)"               
     }
     return nil
}

谢谢大家!

是设备的日期时间,始终需要是正确的小时

是设备的日期时间,始终需要是正确的小时