How to generate thumbnails for Versions created by REST API S3 uploads?

When Version media is manually uploaded to ShotGrid using the ShotGrid Web UI, clickable video thumbnails are rendered and appear in the Thumbnail field

For Version media uploaded using the REST API, no thumbnail is generated.

I wasn’t sure whether that’s due to a mistake in the way I auto-uploaded to S3 or there’s an additional step required for the video thumbnails to be rendered and attached.

Is there a way to use the REST API to create video thumbnails for uploaded Version media?

I’m not familiar with the rest api but to what field did you upload?

This problem I actually managed to resolve.
There are 3 key steps in the process:

  • Requesting the Upload URL
  • Uploading the File using the Upload URL (For Versions, you get an AWS S3 pre-signed URL)
  • Completing the Upload

It was the 2nd step, actually uploading, where I was having trouble. There are no clear examples in the API Documentation nor even in AWS for REST API uploading to S3 using a pre-signed URL.

For me the missing ingredient was that the upload must be binary. In Command Line terms that means using the option --data-binary (not communicated in the docs) instead of merely -d (as suggested by the documentation)

I’m a little surprised this isn’t a burning question for devs – how to upload to AWS S3 for ShotGrid – but if anyone wants an example I’ll dig out the code and post it.

1 Like

Examples always welcome!

I think the majority of us are on the Python API…

1 Like

Python. I saw that. It’s a VFX standard, but that’s the other ongoing surprise, not that people use Python, but that REST isn’t considered essential. If you know the REST approach, you can run it in any language you want – Python, NodeJS, C, C++ etc. From my perspective REST is foundational. Python and JS Libraries merely package (and effectively obscure) a process that is pretty accessible to anyone who’s comfortable coding.

1 Like

Here’s a schematic example for REST uploading to the Version entity via AWS S3

Request the Upload URL

curl -X GET \
'{YourSgDomain}/api/v1/entity/versions/{IdOfYourTargetVersion}/sg_uploaded_movie/_upload?filename={YourFileName}' \
-H 'Authorization: Bearer {YourToken}' \
-H 'Accept: application/json'

This will return a pre-signed AWS S3 upload URL. You’ll use that in the next step.
This will also return complete_upload dataset, including a link associated with that dataset. Use those in the final step below.

Execute the Upload

curl -X PUT \
'{YourPreSignedAwsUrl}' \
--data-binary '@{PathToFileYouWantToUpload}' \
-H 'Content-Type: {MimeTypeOfYourUpload}' \
-H 'Content-Size: {SizeOfYourFileInBites}'

Finalize the Upload

curl -d '{"upoad_info":"{DataFromComplete_Upload}", "upload_data":"{YourFileName}"}' \
'{YourSgDomain}/{LinkForYourComplete_Upload}` \
-H 'Accept: application/json' \
-H 'Content-Type: application/json' \
-H 'Authorization: Bearer {YourToken}'

Thanks that’s interesting…

Still way more lines than python :stuck_out_tongue:

Wrap it in JS and apply!! :stuck_out_tongue_winking_eye: