Need to see if your shared folder is taking up space on your dropbox 👨‍💻? Find out how to check here.

Forum Discussion

taulant's avatar
taulant
Explorer | Level 4
2 years ago
Solved

Encountering server timeout on App Engine while attempting to retrieve thumbnails, even with Pagin..

Encountering server timeout on App Engine while attempting to retrieve thumbnails, even with Pagination
 
Is there a simpler way to get the thumbnails? 
I would highly appreciate some help!
 
public ImageResult getFolderImageContents(String folderPath) {
List<ImageInfo> images = new ArrayList<>();
String cursor = null;
try {
DbxClientV2 dbxClient = dropboxClientProvider.getDropboxClient();
ListFolderResult results = dbxClient.files().listFolder(folderPath);

for (Metadata metadata : results.getEntries()) {
if (metadata instanceof FileMetadata) {
FileMetadata fileMetadata = (FileMetadata) metadata;
String fileName = fileMetadata.getName();
String extension = fileName.substring(fileName.lastIndexOf('.') + 1).toLowerCase();
if (isImageFile(extension)) {
ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
dbxClient.files().getThumbnailBuilder(fileMetadata.getPathLower())
.withFormat(ThumbnailFormat.PNG)
.withSize(ThumbnailSize.W64H64)
.download(outputStream);
byte[] thumbnailData = outputStream.toByteArray();

images.add(new ImageInfo(fileMetadata.getName(), thumbnailData, fileMetadata.getPathDisplay()));
}
}
}

if (results.getHasMore()) {
cursor = results.getCursor();
}

} catch (Exception e) {
e.printStackTrace();
}

return new ImageResult(images, cursor);
}
  • Just to clarify, do you mean you're getting a timeout from the Dropbox API, or that some operation on your server is timing out while performing these Dropbox API calls?

     

    Regardless, the Dropbox API does offer a way to get thumbnails in batches. In the Dropbox Java SDK, that's available via the getThumbnailBatch method.

2 Replies

Replies have been turned off for this discussion
  • Greg-DB's avatar
    Greg-DB
    Icon for Dropbox Community Moderator rankDropbox Community Moderator
    2 years ago

    Just to clarify, do you mean you're getting a timeout from the Dropbox API, or that some operation on your server is timing out while performing these Dropbox API calls?

     

    Regardless, the Dropbox API does offer a way to get thumbnails in batches. In the Dropbox Java SDK, that's available via the getThumbnailBatch method.

  • taulant's avatar
    taulant
    Explorer | Level 4
    2 years ago

    Thank you for your guidance, Graig! It turns out the timeout issue was indeed on my server's end, not with Dropbox. I wasn't familiar with the getThumbnailBatch method you mentioned, but after implementing it, everything is working smoothly. Your quick response was incredibly helpful and pointed me in the right direction. Much appreciated!

About Discuss Dropbox Developer & API

Node avatar for Discuss Dropbox Developer & API
Make connections with 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!