0

In old BOX API, I have shown the thumbnail as this method.

<img src="https://api.box.com/2.0/files/{file_ID}/thumbnail.png?access_token={token}">

However, recently, taking of the thumbnail fails.

It seems that there is no declaration of mime-type in the response header from BOX(Because some browsers shows this data as binary array). If this is not a bug, how should I display a thumbnail?

John Hoerr
  • 7,955
  • 2
  • 30
  • 40
Tank2005
  • 899
  • 1
  • 14
  • 32

1 Answers1

0

The documentation explains how to retrieve a thumbnail for a file and includes a cURL example:

curl https://api.box.com/2.0/files/FILE_ID/thumbnail.png?min_height=256&min_width=256 \
-H "Authorization: Bearer ACCESS_TOKEN"

Note that the access token is given in the authorization header and not as a query parameter.

I'd be really surprised if this used to work. Access tokens expire every hour, so after an hour the image would stop loading. You should also be really careful when including an access token in markup. Anyone that can see that image source URL would be able to gain access to the account (until the token expires).

Greg
  • 3,731
  • 1
  • 29
  • 25
  • I wrote this code because there are no other ways. Do you know how to display a thumbnail on img tag? – Tank2005 Apr 13 '15 at 04:48
  • It really depends on how your app is built and what you're trying to accomplish. You can either download the image server side and include it in your HTML, or use JavaScript to make an async request with the correct authorization header. I don't believe there's a direct way to link to a thumbnail in an img tag. – Greg Apr 13 '15 at 07:05