Representations availability
Hello,
we are using the Box API to download representations of files uploaded to Box. We noticed that upon upload of a new PPTX file, the preview thumbnail was not yet present in the representations list. After some time, the thumbnail was there.
It seems the thumbnail has not yet been generated at the beginning. Is that right? When are the thumbnails for PPTX generated? Upon uploading, or upon first viewing the file?
Also: is there some event or logic that tells us that the representations are now ready? How can we differ between the case a) thumbnails are not there because not supported and b) thumbnails are not there because they have not yet been generated.
Thank you!
-
Hi Reinhard
Please see the guide here that mentions Asynchronous Thumbnail creation https://developer.box.com/guides/representations/thumbnail/#asynchronous-thumbnail-creation
Also looks at the response section on the endpoint documentation: https://developer.box.com/reference/get-files-id-thumbnail-id#response
Specifically
202: Sometimes generating a thumbnail can take a few seconds. In these situations the API returns a
Location
-header pointing to a placeholder graphic for this file type.
The placeholder graphic can be used in a user interface until the thumbnail generation has completed. TheRetry-After
-header indicates when to the thumbnail will be ready. At that time, retry this endpoint to retrieve the thumbnail.302: Returns an error when Box is not able to create a thumbnail for this file type.
Instead, a
Location
-header pointing to a placeholder graphic for this file type will be returned.Best regards,
Peter Christensen, Platform Solutions Engineer, Box
-
Hi
I think the thumbnail API is actually deprecated but you can achieve the same with the representations API
https://developer.box.com/guides/representations/thumbnail-representation/#the-process should explain but process is the same. If you get a location header back and a retry-after header you can display the temporary image and try again after the retry-header specified time.
Peter
-
I understand. There is no event or similar emitted from box when the thumbnail is ready. As this is an asynchronous process we cannot guarantee when the thumbnail is ready so you will have to use some kind of polling mechanism.
If you use eg our Node SDK you can see that there is some logic built in to wait for the thumbnail to be ready
https://github.com/box/box-node-sdk/blob/main/src/managers/files.ts#L122
Post is closed for comments.
Comments
5 comments