Skip to content

Instantly share code, notes, and snippets.

@nickmalcolm
Created April 15, 2015 21:02
Show Gist options
  • Save nickmalcolm/776d3b46108445fac70e to your computer and use it in GitHub Desktop.
Save nickmalcolm/776d3b46108445fac70e to your computer and use it in GitHub Desktop.
The code we use to paginate through results.
result = @client.execute api_method: @client.drive.files.list, parameters: {
q: "trashed=false and mimeType != 'application/vnd.google-apps.folder'",
pageToken: page_token,
fields: "etag,items(etag,sharingUser,writersCanShare,thumbnailLink,lastModifyingUser,alternateLink,indexableText,owners,id,modifiedByMeDate,description,embedLink,folderColorRgb,thumbnail,downloadUrl,originalFilename,iconLink,editable,exportLinks,mimeType,createdDate,modifiedDate,headRevisionId,lastViewedByMeDate,webViewLink,fileExtension,webContentLink,labels,fileSize,quotaBytesUsed,markedViewedByMeDate,userPermission,defaultOpenWithLink,videoMediaMetadata,appDataContents,imageMediaMetadata,permissions,kind,version,ownerNames,copyable,parents,title,properties,selfLink,shared,lastModifyingUserName,openWithLinks,sharedWithMeDate,md5Checksum,explicitlyTrashed),kind,nextLink,nextPageToken,selfLink"
}
@nickmalcolm
Copy link
Author

@client is set up earlier, with an Customer's OAuth token. Only page_token changes, as we iterate through pages, and that comes from the result's nextPageToken.

This code works fine for ~1500 pages, but for no apparent reason will return a 500 response.

@nickmalcolm
Copy link
Author

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment