We are aware of the issue with the badge emails resending to everyone, we apologise for the inconvenience - learn more here.

Forum Discussion

taulant's avatar
taulant
Explorer | Level 4
10 months ago

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.

  • 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

      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!