Getting no response from an pre-signed URL upload to S3

0

I'm working with AutoDesk ShotGrid (aka ShotGun), which involves requesting a pre-singed AWS S3 "Upload URL".

The Upload URL request works just fine. Executing the upload itself produces no errors, but it also produces no response at all.

Here's the upload request:

curl -v -X PUT [Pre-Signed-AWS-UploadUrl] \
-d '@[Path/To/Upload/File.mov]' \
-H 'Content-Type: video/quicktime' \
-H 'Content-Size: [File-Size-Calculated-by-NodeJs-fs.statSync(Path/To/Upload/File.mov).size]' \
-H 'x-amz-meta-original_filename=[NameOfUploadedFile].mov'

The curl call completes (i.e. doesn't hang), but returns and empty string. I believe the response from AWS should be (but isn't)

{
  "data": {
    "upload_id": "Long-ID-Number",
    "original_filename": "[NameOfUploadedFile].mov"
  },
  "links": {
    "complete_upload": "[Some-URL-TBD]"
  }
}

Instead there's no return. Just an empty string.

1 Answer
0

Why do you believe you should be getting that response back?

According to the S3 PutObject API docs, the response elements returned consist entirely of HTTP headers. No body value is expected. As a test, I generated an S3 PUT Presigned URL and then used Postman to successfully upload an .mov file using the URL, and got back:

HTTP Status: 200 OK

No Body

KEYVALUE
x-amz-id-29RzTWsGkgJKVGG6cChR+vYObpTmkglkAYPa7Vk0tTLroWcgwutio ... A88d0=
x-amz-request-id57¥4274R ... O
DateWed, 05 Jan 2022 02:07:39 GMT
ETag"6c7340bed691689395e8b ... 76"
ServerAmazonS3
Content-Length0

I also tried the same using your Curl syntax, but I needed to replace -d with --data-binary. Using -d caused Curl to upload the file using content-type application/x-www-form-urlencoded regardless of whether you provide the -H Content-Type value or not, resulting in a smaller file uploaded and not able to be opened as a video.

Here is the result I got using CURL:

$ curl -v -X PUT 'https://XX-XXXXXXX.s3.amazonaws.com/file_example_MOV_480_700kB.mov?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=XXXXXXXXXXXXXXXXXXXX%XXXXXXXXXX%2Fus-east-1%2Fs3%2Faws4_request&X-Amz-Date=20220105T025903Z&X-Amz-Expires=900&X-Amz-SignedHeaders=host&X-Amz-Signature=XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX' \
--data-binary '@./file_example_MOV_480_700kB.mov' \
-H 'Content-Type: video/quicktime' \
-H 'Content-Size: 709764' \
-H 'x-amz-meta-original_filename=file_example_MOV_480_700kB.mov'
* Connected to XX-XXXXXXX.s3.amazonaws.com (54.XXX.XXX.XX) port 443 (#0)
* ALPN, offering h2
* ALPN, offering http/1.1
* successfully set certificate verify locations:
*  CAfile: /Users/XXXXXXXX/.pyenv/versions/3.9.6/lib/python3.9/site-packages/certifi/cacert.pem
*  CApath: none
* TLSv1.2 (OUT), TLS handshake, Client hello (1):
* TLSv1.2 (IN), TLS handshake, Server hello (2):
* TLSv1.2 (IN), TLS handshake, Certificate (11):
* TLSv1.2 (IN), TLS handshake, Server key exchange (12):
* TLSv1.2 (IN), TLS handshake, Server finished (14):
* TLSv1.2 (OUT), TLS handshake, Client key exchange (16):
* TLSv1.2 (OUT), TLS change cipher, Change cipher spec (1):
* TLSv1.2 (OUT), TLS handshake, Finished (20):
* TLSv1.2 (IN), TLS change cipher, Change cipher spec (1):
* TLSv1.2 (IN), TLS handshake, Finished (20):
* SSL connection using TLSv1.2 / ECDHE-RSA-AES128-GCM-SHA256
* ALPN, server did not agree to a protocol
* Server certificate:
*  subject: C=US; ST=Washington; L=Seattle; O=Amazon.com, Inc.; CN=*.s3.amazonaws.com
*  start date: Jan 11 00:00:00 2021 GMT
*  expire date: Feb 11 23:59:59 2022 GMT
*  subjectAltName: host "XX-XXXXXXX.s3.amazonaws.com" matched cert's "*.s3.amazonaws.com"
*  issuer: C=US; O=DigiCert Inc; OU=www.digicert.com; CN=DigiCert Baltimore CA-2 G2
*  SSL certificate verify ok.
> PUT /file_example_MOV_480_700kB.mov?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=XXXXXXXXXXXXXXXXXXXX%2F20220105%2Fus-east-1%2Fs3%2Faws4_request&X-Amz-Date=20220105T025903Z&X-Amz-Expires=900&X-Amz-SignedHeaders=host&X-Amz-Signature=XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX HTTP/1.1
> Host: XX-XXXXXXX.s3.amazonaws.com
> User-Agent: curl/7.77.0
> Accept: */*
> Content-Type: video/quicktime
> Content-Size: 709764
> Content-Length: 709764
> 
* We are completely uploaded and fine
* Mark bundle as not supporting multiuse
< HTTP/1.1 200 OK
< x-amz-id-2: st/XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX=
< x-amz-request-id: XXXXXXXXXXXXXXXX
< Date: Wed, 05 Jan 2022 03:09:46 GMT
< ETag: "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
< Server: AmazonS3
< Content-Length: 0
< 
* Connection #0 to host XX-XXXXXXX.s3.amazonaws.com left intact
AWS
Scott_K
answered 2 years ago
  • @Scott_K thanks for all that detail. RE: "Why do you believe you should be getting that response back?" -- You're right. It was a misread of their API on my part (You get the JSON response when an upload goes to the ShotGrid servers, but not to S3).

    So thanks for your pointing that out. The response you show above I also see (on the StdErr stream, aka stream 2 or progress stream for cURL calls). I haven't figured out how to view the uploaded media QuickTime file.

  • @Scott_K - Looking more carefully, I wonder if this is relevant:

    I get a mismatch between Content-Size and Content-Length. Yours match.

    My Content-Size (derived from the file) is 6596092 (over 6mb)

    The Content-Length is generated by the cURL request and shows 2047460 (about 2mb)

    Not sure if that's significant. Perhaps the file isn't getting fully uploaded? The only other clue I've got is comes from the ShotGrid side which I can see attempts to transcode the uploaded file and then fails. When I upload using the ShotGrid Browser UI the file uploads just fine. Only the API fails.

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.

Guidelines for Answering Questions