1

I am trying learn the ropes of libcurl and s3, to PUT(single) a file into s3 the libcurl request I make is like

CURLOPT_URL:
http://my_bucket.s3.amazonaws.com/my_file.ppi 

CURLOPT_HTTPHEADER(s):
PUT /my_file.ppi HTTP/1.1
Host: my_bucket.s3.amazonaws.com
Date: date
Authorization: authorization string  

this works fine. For a multi-part request, the init upload libcurl request is

CURLOPT_URL: 
http://my_bucket.s3.amazonaws.com/my_file.ppi?uploads

CURLOPT_HTTPHEADER(s):
POST /myfile.ppi?uploads HTTP/1.1
Host: my_bucket.s3.amazonaws.com
Date: date
Authorization: authorization string
x-amz-content-sha256: STREAMING-AWS4-HMAC-SHA256-PAYLOAD

this is successful and get the upload id. Then when doing the actual part upload, no matter what the url and PUT header I give s3 throws back error saying method not implemented.

CURLOPT_URL: 
http://my_bucket.s3.amazonaws.com/my_file.ppi?uploads(??)

CURLOPT_HTTPHEADER(s):
PUT /myfile.ppi?partNumber=1&uploadId=qEBsy9IVnBf9Cp3yaQwWq18cm... HTTP/1.1
Host: my_bucket.s3.amazonaws.com
Date: date
Authorization: authorization string   
x-amz-content-sha256: 2ccd1c4....

What am I doing wrong here? I set CURLOPT_UPLOAD to 1 are there any other libcurl options I need to set? What should the url and PUT header look like?

Thanks In Advance

user3592909
  • 23
  • 1
  • 3

1 Answers1

0

Amazon S3 still doesn't support Chunked Transfer Encoding on request, so you have to specify the size of the uploaded object (which libcurl will then sends in the Content-Length header) using CURLOPT_INFILESIZE_LARGE.

Remi Gacogne
  • 4,655
  • 1
  • 18
  • 22