AWSS3TransferUtility错误:错误域= kCFErrorDomainCFNetwork代码= 310“(null)”

时间:2019-08-26 01:06:38

标签: swift aws-amplify aws-appsync awss3transferutility

我从https://github.com/awslabs/aws-sdk-ios-samples/tree/master/S3TransferUtility-Sample/Swift下载了适用于AWSS3TransferUtility的示例SWift iOS项目,并按照所有概述的步骤使用S3TransferUtility将图像上传到s3,并使用Xcode 10.3和Swift 5将其运行到iOS 12.4模拟器。该项目虽然导致错误。提供的项目链接中的步骤很容易执行,包括:放大init,放大推送,放大添加存储,放大推送。

我还在文档(https://aws-amplify.github.io/docs/ios/storage)中尝试了相同的步骤,但是导致了相同的错误:

@objc func uploadImage(with data: Data) {
        let expression = AWSS3TransferUtilityUploadExpression()
        expression.progressBlock = progressBlock

        DispatchQueue.main.async(execute: {
            self.statusLabel.text = ""
            self.progressView.progress = 0
        })

        transferUtility.uploadData(
            data,
            key: S3UploadKeyName,
            contentType: "image/png",
            expression: expression,
            completionHandler: completionHandler).continueWith { (task) -> AnyObject? in
                if let error = task.error {
                    print("Error: \(error.localizedDescription)")


                     DispatchQueue.main.async {
                         self.statusLabel.text = "Failed"
                     }
                 }

                 if let _ = task.result {

                     DispatchQueue.main.async {
                         self.statusLabel.text = "Uploading..."
                         print("Upload Starting!")
                     }

                     // Do something with uploadTask.
                 }

                 return nil;
         }
     }
 }

由于auth和nonauth步骤(按照步骤中的指示)允许对s3进行读取和写入,因此我希望将文件上传到S3。但是,实际输出是此错误:

Failed with error: Error Domain=kCFErrorDomainCFNetwork Code=310 "(null)" UserInfo={_NSURLErrorFailingURLSessionTaskErrorKey=BackgroundUploadTask <B9127583-F898-4208-B7F7-556370EF4276>.<2>, _kCFStreamErrorDomainKey=4, _NSURLErrorRelatedURLSessionTaskErrorKey=(
    "BackgroundUploadTask <B9127583-F898-4208-B7F7-556370EF4276>.<2>",
    "LocalUploadTask <B9127583-F898-4208-B7F7-556370EF4276>.<2>"
), _kCFStreamErrorCodeKey=-2096}

0 个答案:

没有答案