Agent-first file upload and publish service built on Cloudflare Pages Functions, R2, and D1.
- Website:
https://www.okfile.com - Repository:
https://github.com/okfilecom/okfile - License:
Apache-2.0
OkFile is designed for Agents, scripts, and lightweight manual upload use cases.
It supports:
- anonymous uploads
- authenticated uploads with user API keys
- direct file URLs for download or embedding
- preview/playback URLs for image, video, and PDF
- multipart upload for large files up to
500MB - retrying only missing parts after incomplete multipart uploads
- email magic-link login and account management
- localized home, upload, and account pages
POST /api/upload/preparePUT uploadUrlor eachparts[].uploadUrlPOST /api/upload/complete- return
urland optionallyplayUrl
- request a magic link and log in
- create an API key in
/account - call
POST /api/upload/preparewithapiKey - upload file data to signed URLs
- call
POST /api/upload/complete
Users can also use:
/zh/upload//en/upload/
This path is kept as a fallback entry, while API integration remains the recommended flow.
- Cloudflare Pages Functions for routing and API handling
- Cloudflare R2 for file storage
- Cloudflare D1 for auth and API key metadata
- Resend for email magic links
- static
index.htmlfor homepage - static
upload.htmlfor manual upload - server-side localization and SEO injection in
worker-app.js
- issue presigned R2 upload URLs
- complete multipart uploads
- activate public file routes
- manage sessions, magic links, and API keys
- enforce anonymous and per-key quota limits
/zh/and/en/: localized home pages/zh/upload/and/en/upload/: manual upload pages/account: redirects to localized account page/zh/account/and/en/account/: localized account pages/admin: admin console
POST /api/upload/preparePOST /api/upload/completeGET /api/upload/status/{id}
POST /api/auth/request-linkGET /auth/verify?token=...GET /api/account/mePOST /api/account/api-keys
/i/{id}: direct file URL/i/{id}?play=1: preview/playback page/d/{id}: controlled download route
.
|- worker-app.js # main Pages Function entry
|- index.html # homepage
|- upload.html # manual upload page
|- schema.sql # D1 schema
|- wrangler.toml # Cloudflare config
|- SKILL.md # root skill document
|- .trae/skills/okfile/SKILL.md # Trae skill definition
|- okfile-upload-pitfalls.md # upload pitfalls and debugging notes
Install dependencies:
npm installRun local development:
npx wrangler pages dev .Deploy to Cloudflare Pages:
npx wrangler pages deploy . --project-name okfile --branch mainStore secrets in Cloudflare, not in the repository.
R2_ACCESS_KEY_IDR2_SECRET_ACCESS_KEYRESEND_API_KEY
R2_ACCOUNT_IDRESEND_FROM_EMAILADMIN_EMAILS
The D1 schema is defined in schema.sql and includes:
usersmagic_linkssessionsapi_keysapi_key_usage_windows
See these repo docs for integration details:
SKILL.md.trae/skills/okfile/SKILL.mdokfile-upload-pitfalls.md
The pitfalls doc includes practical notes such as:
- Cloudflare requiring a normal
User-Agentfor some requests - explicit
Content-Lengthon R2 PUT - multipart retry strategy
- large-file client recommendations on Windows
Please read CONTRIBUTING.md before opening pull requests.
Please read SECURITY.md for reporting instructions and secret-handling rules.
See CHANGELOG.md for release notes tracked in-repo.
Apache-2.0