Gdrive Upload
@tagur/gdrive-uploadv2026.10.26.1
01README
Upload local files into Google Drive (My Drive), under a named folder.
Auth is a Google OAuth access token with Drive scope, wired from a vault
(e.g. @atalanta/gcloud-token, which mints one per run from the gcloud
CLI). The token is treated as sensitive and never stored in a resource.
IMPORTANT — quota project: with user Application Default Credentials the
Drive API rejects requests that have no quota project (HTTP 403 "requires a
quota project"). This behavior sends x-goog-user-project: <quotaProject>
on every call, so set quotaProject to a GCP project id with the Drive API
enabled. See the README.
Methods:
ensure-folder— find a folder by name under a parent (default My Drive root), creating it if absent. Idempotent; records the folder id.upload-file— multipart-upload one local file into a folder under a chosen name.upload-many— upload a batch of files in one run (fan-out); continues past individual failures and reports them.
Quick Start
swamp extension pull @tagur/gdrive-upload
swamp extension pull @atalanta/gcloud-token
# A Drive-scoped token source (needs the gcloud CLI logged in with Drive).
gcloud auth login --enable-gdrive-access
swamp vault create @atalanta/gcloud-token gdrive-token \
--config '{"gcloudPath":"/opt/homebrew/bin/gcloud","scopes":"https://www.googleapis.com/auth/drive"}'
swamp behavior create @tagur/gdrive-upload gdrive \
--global-arg 'accessToken=${{ vault.get("gdrive-token","ACCESS_TOKEN") }}' \
--global-arg 'quotaProject=my-gcp-project'
swamp behavior run gdrive ensure-folder --arg name=Inbox --arg parentId=root
swamp behavior run gdrive upload-file \
--arg path=/tmp/report.pdf --arg name='report.pdf' \
--arg folderId=<id-from-ensure-folder>02Behaviors
@tagur/gdrive-uploadv2026.10.26.1gdrive_upload.ts
Global Arguments
| Argument | Type | Description |
|---|---|---|
| accessToken | string | Google OAuth access token with Drive scope. Wire from the |
| quotaProject | string | GCP project id sent as x-goog-user-project. Required for user ADC: the |
| timeoutMs? | number | Per-request timeout in milliseconds (uploads can be large). |
fn ensure-folder(name: string, parentId?: string)
Find a non-trashed folder by exact name under a parent (default My
| Argument | Type | Description |
|---|---|---|
| name | string | Folder name, e.g. Inbox. |
| parentId? | string | Parent folder id. 'root' is My Drive's top level. |
fn upload-file(path: string, name: string, folderId: string, mimeType?: string)
Multipart-upload one local file into a Drive folder under a chosen
| Argument | Type | Description |
|---|---|---|
| path | string | Absolute path of the local file. |
| name | string | Filename to create in Drive (e.g. '2026-10-24 - Subject - orig.pdf'). |
| folderId | string | Destination folder id from ensure-folder. |
| mimeType? | string | MIME type; defaults to application/octet-stream. |
fn upload-many(folderId: string, files: array)
Upload a batch of local files into one Drive folder in a single run
| Argument | Type | Description |
|---|---|---|
| folderId | string | Destination folder id. |
| files | array | Files to upload: path (local), name (Drive), optional mimeType. |
Resources
folder(infinite)— A resolved (found or created) Drive folder and its id.
upload(infinite)— A file uploaded to Drive: its id, name, and parent folder.
batch(infinite)— Per-file results of an upload-many batch (ok/failed, ids, links).
03Stats
A
100 / 100
Downloads
0
Archive size
11.8 KB
- Has README or module doc2/2earned
- README has a code example1/1earned
- README is substantive1/1earned
- Most symbols documented1/1earned
- No slow types (deprecated)1/1earned
- Dependencies pass trust audit2/2earned
- Docs keep secrets in a vault1/1earned
- Has description1/1earned
- Platform support declared (or universal)2/2earned
- License2/2earned
- Verified public repository2/2earned
04Platforms
05Labels