Open-source object storage, on the Drive you already have
Use Google Drive
as object storage.
Store your app's photos, documents and backups in Google Drive instead of S3. It speaks the S3 API, so your existing @aws-sdk/client-s3 code works by changing endpoint.
Set up drivebucket
Get a refresh token, check the setup and create your first bucket:
$ npx @drivebucket/cli auth login --client-id ID --client-secret SECRET > .env $ npx @drivebucket/cli --env-file .env doctor $ npx @drivebucket/cli --env-file .env buckets create photos
Before you run it
- In Google Cloud Console, enable the Google Drive API.
- Create an OAuth client of type Desktop app.
- Publish the consent screen. In Testing mode, refresh tokens expire after 7 days.
Full walkthrough: Quick start in the README →
Source, issues and releases. MIT licensed.
Quickstarts for Express, Next.js and Docker, plus S3 migration.
Four packages, published with provenance.
How it works
drivebucket maps the object-storage model onto Drive. Buckets become folders, objects become files, and your keys live in private file properties that only your app can see.
-
Bucket = folder
Each bucket is a folder under one root: a folder the app creates in My Drive, or a shared drive on Workspace.
-
Object = file
Files sit flat in the bucket folder. The key, bucket and a SHA-256 lookup hash are stored in
appProperties, and a key → file-id cache (memory, Redis or MongoDB) skips the search. -
Served by you, not Drive
Uploads are MD5-checked end to end. Reads stream through your server with byte ranges and resizing. Files are never shared publicly in Drive.
How a photo travels through drivebucket, in 54 seconds. Turn the sound on.
Four packages
Use the adapter directly, put the S3-compatible server in front of it, or drop the Next.js route into your app.
The DriveAdapter: buckets, put/get/head/list/copy/delete, resumable uploads, retries with backoff and a pluggable key index.
Docker image with an S3-compatible API (SigV4, presigned URLs, multipart), a public read proxy, image resizing and Prometheus metrics.
Next.js App Router route for uploads and serving, plus browser-side resize and upload with progress.
auth login with loopback OAuth, doctor to check your setup, and buckets, ls, cp, rm.
Pick your integration
Three ways in. Each one has a full guide in the docs.
import { S3Client, PutObjectCommand } from '@aws-sdk/client-s3'; const s3 = new S3Client({ endpoint: 'https://files.example.com', // your drivebucket-server forcePathStyle: true, region: 'us-east-1', credentials, }); await s3.send(new PutObjectCommand({ Bucket: 'photos', Key: 'cat.jpg', Body, ContentType: 'image/jpeg', }));
Keep your S3 code
Point the AWS SDK at drivebucket-server. Signatures, presigned URLs and multipart uploads work as they do on S3.
It's a subset: path-style only, with no versioning, ACLs or object lock.
import { DriveAdapter, driveOptionsFromEnv } from '@drivebucket/core'; import { createDriveRoute } from '@drivebucket/next'; export const runtime = 'nodejs'; export const { GET, HEAD, POST } = createDriveRoute({ adapter: () => new DriveAdapter(driveOptionsFromEnv()), bucket: 'photos', maxBytes: 12 * 1024 * 1024, allowedTypes: ['image/*'], });
Upload from the browser
uploadFile() from @drivebucket/next/client downscales images to WebP before upload and returns the key to save in your database.
File types are checked from the bytes, so an HTML file can't pose as image/png.
# server + Redis key index $ cp docker-compose.example.yml docker-compose.yml $ docker compose up -d $ curl localhost:8080/-/ready # resized, cacheable image URLs https://files.example.com/photos/cat.jpg?w=640&format=webp
Put a CDN in front
Every uncached read is a Drive download costing 200 quota units; a cached one costs nothing. Cloudflare in front of the proxy keeps reads fast and cheap.
The limits, up front
Drive is not S3. drivebucket works well for an app with thousands of users and a CDN in front. Read these before you rely on it.
| Limit | Value | What it means |
|---|---|---|
| Upload volume | 750 GB / user / day | After that, uploads and copies fail for 24 hours. |
| API quota | 325,000 units / min | An uncached download costs 200 units: about 27 per second per user. |
| Objects per bucket | ~500,000 | Drive's per-folder cap. Shard across buckets beyond that. |
| Listing | Scans the bucket | Drive can't filter by prefix. Fine for thousands of objects, costly for hundreds of thousands. |
| Consistency | No atomic conditional writes | If-Match is best effort; concurrent writers can race. |
| Object size | 5 TB | Uploads above 5 MB use resumable sessions. |
Good fit
- User uploads for small and medium apps
- Side projects that shouldn't pay a storage bill
- Teams already paying for Workspace storage
- Backups and documents behind your own auth
Use real object storage for
- A busy public CDN origin without a cache
- Millions of objects per bucket or a data lake
- Strong consistency, residency or object lock
- Serving video at scale
Full table, Google's terms and abuse notes: Limits in the README →
Documentation
Guides live in the repository. Start with the one that matches your stack.
Google Cloud setup, refresh token and first bucket.
DriveAdapter with a streaming multer storage engine.
createDriveRoute() and uploadFile() with client-side resize.
S3 endpoint and public image proxy behind a CDN.
Copy data with rclone, change endpoint, check what differs.
Quotas, property limits and how Drive v3 behaves.
Environment variables, S3 API coverage and resizing.
Runnable Express and Next.js photo-upload apps.
Develop locally and test against a fake Drive.