cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Announcements
Are you using the Microsoft co-authoring beta for Dropbox? Share your feedback and learn more about it here.

Discuss Dropbox Developer & API

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

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 Pagin..

taulant
Explorer | Level 4
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);
}
1 Accepted Solution

Accepted Solutions

Greg-DB
Dropbox Staff

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.

View solution in original post

2 Replies 2

Greg-DB
Dropbox Staff

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
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!

Need more support?
Who's talking

Top contributors to this post

  • User avatar
    taulant Explorer | Level 4
  • User avatar
    Greg-DB Dropbox Staff
What do Dropbox user levels mean?