当我尝试将文本文件从本地设备上载到aws s3存储桶时,导致Message的正文错误:您未提供Content-Length HTTP标头指定的字节数。请查看下面的代码段。
let uploadRequest = AWSS3TransferManagerUploadRequest()!
uploadRequest.body = localTextURL
uploadRequest.key = filename
uploadRequest.bucket = S3BucketName
uploadRequest.contentLength = 2849623
let transferManager = AWSS3TransferManager.default()
transferManager.upload(uploadRequest).continueWith(executor:
AWSExecutor.mainThread(),block: { (task) -> AnyObject! in
if let error = task.error {
print("Upload failed (\(error))")
}
if task.result != nil {
print("uploaded to \(task.result)")
}
else {
print("Unexpected empty result.")
}
return nil
})