Want to know more about How We Use Dash? Check out how Josh Clemm uses Dash here.
Forum Discussion
Penka V.
10 years agoNew member | Level 1
Dropbox API file preview - check the preview content type
Hi,
I am using the Dropbox SDK for Java. I understand that the the get_preview will return either html or pdf based on the file type. Is there a rule that specifies what is the preview content type for each file type? And is that rule likely to change? E.g xls preview is html now, but next week may be pdf?
And is there a way to check what the preview mime type is after we get it from Dropbox? Maybe it is in the response header, but how do I access this form the SDK?
The only way to check the preview type now is to consume the content stream convert to string and check if starts with HTML tag.
Is there a better way?
2 Replies
- Greg-DB10 years ago
Dropbox Community Moderator
Thanks for the report Penka! You're right, it looks like we don't currently return a good indicator of the format used for the preview.
That endpoint does return either HTML or PDF, and that could change for any given sort of file over time, so the right way to handle this is to check the returned format on the fly. I'm sending this along to the team to see how we may be able to expose this properly so you don't have to do the string check you described.
- Greg-DB8 years ago
Dropbox Community Moderator
Apologies for not following up on this sooner. I just wanted to update this to let you know we now officially document which file types give which preview type:
https://dropbox.github.io/dropbox-sdk-java/api-docs/v3.0.x/com/dropbox/core/v2/files/DbxUserFilesRequests.html#getPreview-java.lang.String-
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!