Upload to s3 with curl using pre-signed URL (getting 403)

后端 未结 4 1788
南旧
南旧 2021-02-12 11:59

I\'m using curl to call into a Java ReST API to retrieve a URL. Java then generates a pre-signed URL for S3 upload using my S3 credentials, and returns that in the ReST reply. C

4条回答
  •  粉色の甜心
    2021-02-12 12:28

    I've been able to generate a pre-signed URL via C# and upload it thereafter via curl as expected. Given my tests I suspect you are indeed not using curl correctly - I've been able to upload a file like so:

    curl -v --upload-file ${fileName} ${location}
    

    The parameter -v dumps both request and response headers (as well as the SSL handshake) for debugging and illustration purposes:

    > PUT [...] HTTP/1.1
    > User-Agent: curl/7.21.0 [...]
    > Host: [...]
    > Accept: */*
    > Content-Length: 12
    > Expect: 100-continue
    

    Please note, that --upload-file (or -T) facilitates PUTas expected, but adds more headers as appropriate, yielding a proper response in return:

    < HTTP/1.1 100 Continue
    < HTTP/1.1 200 OK
    < x-amz-id-2: [...]
    < x-amz-request-id:  [...]
    < Date: Tue, 31 Jan 2012 18:34:56 GMT
    < ETag: "253801c0d260f076b0d5db5b62c54824"
    < Content-Length: 0
    < Server: AmazonS3
    

提交回复
热议问题