我正在使用 AWSS3TransferManager 将文件直接上传到 s3。我从上传块收到一条成功消息,但它没有出现在我的 s3 管理控制台的存储桶中。当我直接访问网址时,它会出现。我需要将其添加到存储桶中,因为我的应用程序从 sqs 队列中提取以在数据库中创建对象。
这是我的上传代码:
let uploadFileRequest = AWSS3TransferManagerUploadRequest()
uploadFileRequest.bucket = AWS.S3BucketName
uploadFileRequest.key = uploadFileName
uploadFileRequest.contentType = "video/quicktime"
uploadFileRequest.contentLength = NSNumber(integer: video!.length)
let transferManager = AWSS3TransferManager.defaultS3TransferManager()
uploadFileRequest.body = uploadFileURL!
transferManager.upload(uploadFileRequest).continueWithBlock({ (task) -> AnyObject! in
if task.error != nil {
print("video upload failed \(task.error)")
} else {
print("video upload succeeded")
print("\(uploadFileName)")
}
return 1
})
更新:我认为这可能是一个安全问题。这是我设置 cognito 的代码: let credentialsProvider = AWSCognitoCredentialsProvider(regionType:
AWSRegionType.USEast1, identityPoolId: AWS.cognitoPoolID)
let configuration = AWSServiceConfiguration(region: AWSRegionType.USEast1, credentialsProvider: credentialsProvider)
AWSServiceManager.defaultServiceManager().defaultServiceConfiguration = configuration