Your workflow is unique 👨‍💻 -  tell us how you use Dropbox here.

Forum Discussion

sigrem's avatar
sigrem
New member | Level 1
9 years ago

Fetching video thumbnails in Swifty Dropbox

Hi,

I use the following code to get thumbnail for images and videos (using Swifty Dropbox). It works for images and for many videos but crashes on some other videos. Shouldn't unsuccessful thumb generation be captured in the error section? Is there a Swift counterpart for Android's getThumbnailBuilder? 

func fetchDropboxThumbnail(client: DropboxClient, file: Files.Metadata, toPath: String) {

let destination : (NSURL, NSHTTPURLResponse) -> NSURL = { temporaryURL, response in

            let thumbUrl = NSURL(fileURLWithPath: toPath)

            return thumbUrl

        }

        client.files.getThumbnail(path: file.pathLower, destination: destination).response  { response, error in

            if let response = response {

                print("Assuming thumbnail saved to toPath")

            }

            else {

                print("\(error)")

                // Assuming thumbnail could not be generated

            }

        }

    }

1 Reply

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

    The files.getThumbnail method in the SwityDropbox SDK is the equivalent method for getting thumbnails as getThumbnailBuilder in the Android/Java SDK.

    Anyway, yes, errors from the getThumbnail call should be captured by the error code block. Can you share whatever output/crash you're getting? Also, the parameters you're using may be helpful.

     

About Dropbox API Support and Feedback

Node avatar for Dropbox API Support and Feedback
Get help with the Dropbox API from fellow developers and experts.

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!