我正在尝试使用预签名的请求将一个大的(比如不适合内存)文件上传到 S3。我终于让它与 curl 一起工作
curl -v -T video.mp4 "http://<myBucket>.s3.amazonaws.com/video.mp4?AWSAccessKeyId=<myAccessKey>&Expires=1492187347&Signature=vpcUnvGALlVXju31Qk2nXNmBTgc%3D"
我现在正试图从我的应用程序中做到这一点。我首先尝试使用 AF(我不想使用):
let videoPath = Bundle.main.path(forResource: "media", ofType: "mov")!
let videoUrl = URL(fileURLWithPath: videoPath)
let presignedUrl = "http://<myBucket>.s3.amazonaws.com/video.mp4?AWSAccessKeyId=<myAccessKey>&Expires=1492187347&Signature=vpcUnvGALlVXju31Qk2nXNmBTgc%3D"
request = Alamofire.upload(videoUrl, to: presignedUrl, method: .put, headers: [:])
request.responseString(completionHandler: { response in
print(response)
})
request.resume()
打印一个实际上是错误的成功响应:
The request signature we calculated does not match the signature you provided. Check your key and signing method.
我在一些地方读到标题可能存在问题,无论如何我都不想在这里使用 AF。
Swift 中的等价物是curl -T filePath url
什么?