Upload files to Drive from your code

Upload, organize, and share files in Google Drive programmatically. Folder management, permissions, and batch operations in one API call.

File UploadFolder ManagementPermission SharingBatch Operations
import { Stack0 } from '@stack0/sdk'
import { readFileSync } from 'fs'
const stack0 = new Stack0({ apiKey: process.env.STACK0_API_KEY })
// Upload a file to Google Drive
export async function uploadReport(filePath: string) {
const file = readFileSync(filePath)
const result = await stack0.integrations.storage.upload({
provider: 'google-drive',
file: {
name: 'quarterly-report.pdf',
content: file,
mimeType: 'application/pdf',
},
folder: '/Reports/2025/Q1',
options: {
createFolders: true,
convertTo: 'google-docs',
},
})
return result // { id, name, url, folderId, mimeType }
}
// Upload and share with specific users
export async function uploadAndShare(file: Buffer, name: string) {
const result = await stack0.integrations.storage.upload({
provider: 'google-drive',
file: {
name,
content: file,
mimeType: 'application/pdf',
},
folder: '/Shared/Contracts',
permissions: [
{ email: 'team@example.com', role: 'writer' },
{ email: 'client@external.com', role: 'reader' },
],
})
return result
}
// Batch upload multiple files
export async function uploadBatch(files: FileInput[]) {
const results = await stack0.integrations.storage.batchUpload({
provider: 'google-drive',
files: files.map(f => ({
name: f.name,
content: f.buffer,
mimeType: f.type,
})),
folder: '/Uploads',
})
return results // [{ id, name, url }, ...]
}

What's included

File Upload

Upload any file type up to 5 GB. Resumable uploads for large files.

Folder Management

Create nested folder structures. Organize uploads with path-based routing.

Permission Sharing

Grant access during or after upload. Users, groups, and domain-wide sharing.

File Conversion

Convert PDFs to Google Docs, CSVs to Sheets, and PPTs to Slides automatically.

Batch Operations

Upload multiple files in one call. Parallel processing with individual status.

Metadata Sync

Set descriptions, tags, and custom properties. Search files by metadata later.


Built for production

Simple uploads

Upload files to Google Drive with one API call. No OAuth setup, token management, or scope configuration.

Folder management

Create folder structures automatically. Organize files into nested directories with a single path parameter.

Permission sharing

Grant access to users and groups during upload. Reader, writer, commenter, and owner roles.

File conversion

Convert uploads to Google Docs, Sheets, or Slides. PDFs to editable documents automatically.

TypeScript SDK

Full type safety for files, folders, and permissions. Autocomplete for every option.

Simple pricing

$1 per 1,000 API calls. No storage fees or per-file charges.


Common implementations

Report Distribution

Upload generated reports to shared folders and notify stakeholders automatically.

Document Backup

Archive documents and contracts to Google Drive with organized folder structures.

Team Collaboration

Upload project files to shared drives with the right permissions for each team.

Client Deliverables

Share deliverables with clients via Google Drive links with read-only access.


FAQ

Frequently asked questions

No. Connect your Google account in the Stack0 dashboard with one click. We handle the OAuth flow, token refresh, and scope management. Your API key is all you need in code.

Yes. Set createFolders to true in your upload options. If the folder path doesn't exist, we create the entire directory tree before uploading. Existing folders are reused.

Any file type that Google Drive supports, including documents, spreadsheets, PDFs, images, and videos. You can also convert uploaded files to Google Docs, Sheets, or Slides format using the convertTo option.

Pass a permissions array when uploading to grant access immediately. Roles include reader, writer, commenter, and owner. You can also update permissions on existing files after upload.

Files up to 5 GB are supported, matching Google Drive's own limits. For files over 100 MB, we automatically use resumable uploads to handle network interruptions gracefully.


Ready to build?

Get started in minutes.

Get Started