We’re Still Here to Help (Even Over the Holidays!) - find out more here.
Forum Discussion
FoxyLoxy
4 years agoNew member | Level 2
Acces thumbnail images for PDFs
I'm using Dropbox to store PDF files, and my external application needs to programmatically access a thumbnail image of the first page for each of these PDF files.
These thumbnail images need t...
Greg-DB
Dropbox Community Moderator
4 years agoЗдравко Thanks! That's helpful. I just checked on this, and it looks like that failure is due to an invalid app key and/or secret value, so please double check your values. Additionally, there seems to be a bug on our side with how we handle that error case, resulting in the 500 Internal Server Error being returned, instead of a useful error message/response. I'll ask the team to fix that up.
Здравко
4 years agoLegendary | Level 20
Greg-DB wrote:... it looks like that failure is due to an invalid app key and/or secret value, so please double check your values. ...
Ok, Might be, but there is no reliable way I check it. The following is the way I use to get authentication values. I repeated the test with the same result.
curl -s -S -o ~/dump.txt -D - -g "https://content.dropboxapi.com/2/files/get_thumbnail_v2?arg={\"resource\":{\".tag\":\"link\",\"url\":\"<shared link>\"},\"size\":\"w128h128\"}&authorization=Basic%20$(echo "<app key>:<app secret>" | base64)"Here used values are correct for sure; they are same as above (first command), but fails still (second command). Is the used algorithm wrong? 🤔 I thought it's the same as described, but...
- Greg-DB4 years ago
Dropbox Community Moderator
Здравко You need to use "echo -n " instead of just "echo" in this case. When you don't set "-n", echo includes a trailing newline character which will corrupt your encoded app key/secret value.
- Здравко4 years agoLegendary | Level 20
Waww🤦🤫... that's something really stupid from my side.
But the issue is still there. 🤯 Just the response changes to "Conflict" with body:
{"error_summary": "not_found/", "error": {".tag": "not_found"}}Despite the values are correct. I just checked all them once again. 🤔 Using the same values I can download a thumbnail of the pointed file (values passed as headers).
If you have performed a successful query, can you post the corrected template? 🙏 (just correct the one I posted above; not only the ending new line but whatever is else too)
Add: Full response, if can help:
HTTP/1.1 409 Conflict Server: envoy Date: Wed, 23 Feb 2022 21:27:34 GMT Content-Type: application/json X-Content-Type-Options: nosniff Cache-Control: no-cache Vary: Dropbox-API-Arg, Authorization, Accept-Encoding Content-Disposition: attachment; filename=unspecified Content-Security-Policy: sandbox X-Webkit-Csp: sandbox X-Content-Security-Policy: sandbox Content-Security-Policy: sandbox allow-forms allow-scripts X-Robots-Tag: noindex, nofollow, noimageindex Strict-Transport-Security: max-age=31536000; includeSubDomains; preload X-Robots-Tag: noindex, nofollow, noimageindex X-Dropbox-Response-Origin: remote X-Dropbox-Request-Id: 8302bd4020194fcfb1c64a0201ecae46 Transfer-Encoding: chunked
- Greg-DB4 years ago
Dropbox Community Moderator
Здравко Your code does work for me, as long as I add "-n", and plug in my own app key/secret and shared link. That "not_found" error should indicate an issue with the shared link in this case. Make sure you're supplying a valid and accessible shared link value and are encoding it correctly. For instance, it appears your "arg" URL parameter value is not encoded, though it's not clear if that is how you're sending it or if that's just for illustration purposes.
For example, here's a working version of your code, with the "-n" and an encoded arg containing a sample link:
curl -s -S -o ~/dump.txt -D - -g "https://content.dropboxapi.com/2/files/get_thumbnail_v2?arg=%7B%22resource%22%3A%7B%22.tag%22%3A%22link%22%2C%22url%22%3A%22https%3A%2F%2Fwww.dropbox.com%2Fs%2F1xzftgs96f8ksbx%2Ftest.pdf%3Fdl%3D0%22%7D%2C%22size%22%3A%22w128h128%22%7D&authorization=Basic%20$(echo -n "<app key>:<app secret>" | base64)"- Здравко4 years agoLegendary | Level 20
Thanks Greg-DB,
It's not exactly missing URL encoding, but you drive my to right direction and I found out what's wrong. Since I have used non ASCII symbols in the file name this seems confuses the function. I have no idea why? There is an easy workaround: I just stripped filename in the link; the name isn't mandatory there. Everything works now. 😉
You can take a look if this can be fixed. To reproduce, just rename your "test.pdf" to something like "тест.pdf", for example. It still works while passed as header, but not as parameter! Anyway... I successfully bypassed the issue. 👍
Thanks again!
About Dropbox API Support & Feedback
Find help with the Dropbox API from other developers.
The Dropbox Community team is active from Monday to Friday. We try to respond to you as soon as we can, usually within 2 hours.
If you need more help you can view your support options (expected response time for an email or ticket is 24 hours), or contact us on X, Facebook or Instagram.
For more info on available support options for your Dropbox plan, see this article.
If you found the answer to your question in this Community thread, please 'like' the post to say thanks and to let us know it was useful!