Search code examples
iosswiftgoogle-drive-apithumbnailsvideo-thumbnails

Google Drive API v3 for iOS : How to get thumbnails?


In the past, with Google Drive API v2, I could easily get thumbnails for pictures or videos with the property thumbnailLink on GTLDriveFile.

But now, with the API v3 which I currently use with Swift, the thumbnailLink of the files I get from Google Drive is nil, so what can I do to get thumbnails of images and videos stored in the user's Google Drive. I need to display theses in my iOS app.


Solution

  • Make sure to specify thumbnailLink in fields, such as

    let query = GTLQueryDrive.queryForFilesList()
    query.fields = "files(id, name, thumbnailLink)"
    

    then you can access the property thumbnailLink for images and videos