Problem with thumbnail upload / download

Hey everyone,

I’m facing a strange problem with the thumbnail functionality of our inhouse Shotgrid user interface.
It is based on Python and the current workflow is as follows:

  • The inhouse tool exports a screengrab as a temporary PNG to the users local drive.
  • This local PNG file is then uploaded to Shotgun with the “upload_thumbnail(entity_type, entity_id, source_path)” method of a standard “shotgun_api3.shotgun.Shotgun” object.
  • Then the problem already occurs: Being logged in Shotgrid with my browser, I see that a thumbnail appears for the matching entity, but at first only a placeholder image appears (for example in the list view of all Assets, one asset should receive the new thumbnail, but in the list view it only receives a placeholder).
  • Clicking on the asset, I open the asset detail view and still only the placeholder image appears.
  • When I click on the placeholder image in the detail view, and select “view image”, I get redirected to the Amazon AWS server hosting the image and THE CORRECT IMAGE THUMBNAIL is being shown. So it should already be there.
  • Next step is, our inhouse tool attempts to download the thumbnail image to a local cache by accessing the web address “https://(our-site).shotgunstudio.com/thumbnail/(Entity_Type)/(Entity_ID)” and executing the “tank.util.shotgun.download → download_url(sg, url, location)” method.
  • The downloaded file shows only the placeholder image, not the actual image which is present on the Amazon AWS server. When I enter the above address in the browser, it redirects to the correct image on the AWS server.
  • I’ve been experimenting with adding a time delay between the upload and the download of the thumbnail (trying out between 20 up to 90 seconds) and it seemed like sometimes it returns the correct thumbnail, but even with 90 seconds delay I could not guarantee that the correct thumbnail is being downloaded and not the placeholder.

What is goind wrong here? Is there something that needs to be changed in our Shotgrid server settings or maybe in the upload / download methods?
Or is there no other way than to increase to upload / download delay to some ridiculously high value? Since I can already see the image being there in the browser, I suppose this isn’t the source of the problem.
Best,

Dirk Jansen-Michels
Pipeline TD

This is what the Event Daemon is for.
Basically these actions are not instant - there is synchronization across s3, across regions, etc. - s3 is eventually consistent. That is why ShotGrid provides the Event Daemon to listen to “events”, e.g. when the image completes uploading.
Moreover, some media is transcoded on the ShotGrid server, which also takes time.

Notice that you are accessing the shotgunstudio.com/thumbnail endpoint, which provides just the thumbnail. You should probably use download_attachment for getting the actual image. There is also get_attachment_download_url.

Hi Mois,

thanks for your suggestions, that definitely pointed me in the right direction!
An even easier solution for this particular case was simply to access the “image” field of the entity, and use this url to download the thumbnail. While converting the thumbnail, Shotgrid links the image url to its “thumbnail pending” graphic, so that is an easy way to check if the download should wait or not.
Thank you and best regards,

Dirk