当我在应用程序中上传视频帧时,会引发错误。我在这里复制了代码,有人可以帮助我克服错误吗?
let directoryURL: URL = FileManager.default.urls(for: .documentDirectory, in: .userDomainMask)[0]
let fileURL: URL = directoryURL.appendingPathComponent("test.h264")
let credentialsProvider = AWSCognitoCredentialsProvider(regionType:.USEast1,
identityPoolId:"us-east-1:5338ad28-9e8f-4347-a150-cabb7bc96ff7")
let configuration = AWSServiceConfiguration(region:.USEast1, credentialsProvider:credentialsProvider)
AWSServiceManager.default().defaultServiceConfiguration = configuration
s3Url = AWSS3.default().configuration.endpoint.url
let key = "test.h264"
let request = AWSS3TransferManagerUploadRequest()!
request.bucket = "skilai"
request.key = key
request.body = fileURL
request.acl = .publicReadWrite
request.contentType = "test/h264"
let transferManager = AWSS3TransferManager.default()
transferManager.upload(request).continueWith(executor: AWSExecutor.mainThread()) { (task) -> Any? in
if let error = task.error
{
print("AWS Upload error \(error.localizedDescription)")
}
if task.result != nil
{
print("Uploaded \(key)")
let contentUrl = self.s3Url.appendingPathComponent("skilai").appendingPathComponent(key)
self.contentUrl = contentUrl
}
return nil
}