我想录制一个简短的视频,然后直接上传到minio服务器。我使用aws进行上传,我将.mov转换为.mp4,然后再上传。
let credentialsProvider = AWSStaticCredentialsProvider(accessKey: self.accessKey, secretKey: self.secretKey)
let configuration = AWSServiceConfiguration(region: .Unknown, endpoint: AWSEndpoint(region: .Unknown, service: .S3, url: URL(string:"http://x.x.xxx.xxx:x000/minio")),credentialsProvider: credentialsProvider)
AWSServiceManager.default().defaultServiceConfiguration = configuration
let url = result
let remoteName = "abc.mp4"
let S3BucketName = "abc"
let uploadRequest = AWSS3TransferManagerUploadRequest()!
uploadRequest.body = url!
uploadRequest.key = remoteName
uploadRequest.bucket = S3BucketName
uploadRequest.contentType = "video/mp4"
uploadRequest.acl = .publicRead
// let fileURL = URL(fileURLWithPath: NSTemporaryDirectory()).appendingPathComponent(remoteName)
let transferManager = AWSS3TransferManager.default()
transferManager.upload(uploadRequest).continueWith { (task: AWSTask<AnyObject>) -> Any? in
DispatchQueue.main.async {
}
print("uploadRequest:\(uploadRequest)")
print("task:\(task)")
if let error = task.error {
print("Upload failed with error: (\(error.localizedDescription))")
}
if task.result != nil {
let url = AWSS3.default().configuration.endpoint.url
let publicURL = url?.appendingPathComponent(uploadRequest.bucket!).appendingPathComponent(uploadRequest.key!)
print("Uploaded to:\(String(describing: publicURL!))")
}
return nil
}
这是我从回调获得的错误消息
uploadRequest:{ ACL = 2; 正文=“ file:///private/var/mobile/Containers/Data/Application/10C3C67B-E40E-4479-968B-6611AA59753F/tmp/58298907433__45A90626-CD9A-48EF-8011-B282B63F27CF.mp4”; bucket = abc; cacheIdentifier =“ C2665E02-A434-4E7B-A9B2-65E3CE40B4B9-680-000000750DB6B41F”; contentLength = 113776; contentType =“ video / mp4”; currentUploadingPartNumber = 0; 键=“ abc.mp4”; objectLockLegalHoldStatus = 0; objectLockMode = 0; requestPayer = 0; serverSideEncryption = 0; 状态= 1; storageClass = 0; totalSuccessfullySentPartsDataLength = 0; } 任务: 上传失败,并显示错误:(操作无法完成。(com.amazonaws.AWSS3ErrorDomain错误0。))
我遵循了可以在网上找到的所有步骤,但是不知道出了什么问题,有人可以帮我吗。