REST
storage
Google Drive
List, get, search, upload, and download files from the user's Drive.
Connect Google Drive
Go to /dashboard/connections and click Connect on the Google Drive card to grant OAuth access.
Example
Search the user's Drive for recent quarterly report PDFs.
app/api/find-reports/route.ts
import { Leash } from '@leash/sdk/leash'import { NextRequest } from 'next/server'export async function GET(req: NextRequest) {const leash = new Leash({ request: req })const result = await leash.integrations.drive.searchFiles("name contains 'Q2' and mimeType = 'application/pdf'",10,)// result =>// {// files: [// {// id: '1AbCd...',// name: 'Q2 Revenue Report.pdf',// mimeType: 'application/pdf',// modifiedTime: '2026-04-15T18:21:09.000Z',// webViewLink: 'https://drive.google.com/file/d/1AbCd.../view'// },// ...// ]// }return Response.json(result)}
Available methods
listFiles({ query?, folderId?, maxResults? })— list files, optionally scoped to a folder.getFile(fileId)— fetch a file's metadata.downloadFile(fileId)— download raw file content.searchFiles(query, maxResults?)— Drive-syntax search.uploadFile({ name, content, mimeType, parentId? })— upload a new file.createFolder(name, parentId?)— create a folder.deleteFile(fileId)— delete a file (moves to trash for owned files).
Common gotchas
- Drive query syntax is its own DSL. See search query terms;
contains,=, andinare most useful. - downloadFile returns the raw body, not JSON. Google Docs/Sheets/Slides must be exported with a target MIME type — they have no native binary form.
- uploadFile content must be a base64 string. Encode binary payloads before sending; the SDK does not transform input.
See the Google Drive API reference for the underlying provider docs.
Other languages: see SDK overview for Python and Go.