Python CLI for uploading files and publishing static sites to OkFile
Project description
OkFile
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
What It Does
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 - phase-1 site directory upload with nested subdirectories and per-site subdomain publish URLs
- automatic shared top-level directory stripping for folder-based site uploads
- directory listing fallback when a published site does not contain root
index.html - retrying only missing parts after incomplete multipart uploads
- email magic-link login and account management
- localized home, upload, and account pages
Main User Flows
1. Anonymous Publish
POST /api/upload/preparePUT uploadUrlor eachparts[].uploadUrlPOST /api/upload/complete- return
urland optionallyplayUrl
2. API Key Publish
- 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
3. Manual Upload
Users can also use:
/zh/upload//en/upload/
This path is kept as a fallback entry, while API integration remains the recommended flow.
4. Site Directory Publish
- select a whole folder in
/zh/upload/or/en/upload/ - the uploader preserves nested relative paths
- if every file sits under one shared top-level folder, that folder is stripped and treated as the site root
- if the site contains root
index.html,/renders that page - if root
index.htmldoes not exist,/renders a directory listing with file name, size, and upload time - image and video entries open inline, while other files use download links
Architecture
Runtime
- Cloudflare Pages Functions for routing and API handling
- Cloudflare Worker route for
*.ok26.org/*site subdomains - Cloudflare R2 for file storage
- Cloudflare D1 for auth and API key metadata
- Resend for email magic links
Frontend
- static
index.htmlfor homepage - static
upload.htmlfor manual upload - server-side localization and SEO injection in
worker-app.js
Backend Responsibilities
- issue presigned R2 upload URLs
- complete multipart uploads
- activate public file routes
- resolve published site subdomains from request
Host - manage sessions, magic links, and API keys
- enforce anonymous and per-key quota limits
Core Routes
Pages
/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
Upload APIs
POST /api/upload/preparePOST /api/upload/completeGET /api/upload/status/{id}
Auth APIs
POST /api/auth/request-linkGET /auth/verify?token=...GET /api/account/mePOST /api/account/api-keys
File URLs
/i/{id}: direct file URL/i/{id}?play=1: preview/playback page/d/{id}: controlled download route
Site URLs
https://{subdomain}.ok26.org/: site root or directory listinghttps://{subdomain}.ok26.org/path/to/file: published site asset or documenthttps://{subdomain}.ok26.org/path/to/file?download=1: force download for a site file
Repository Layout
.
|- 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
Local Development
Install dependencies:
npm install
Run local development:
npx wrangler pages dev .
Deploy to Cloudflare Pages:
npx wrangler pages deploy . --project-name okfile --branch main
Configuration
Store secrets in Cloudflare, not in the repository.
Secrets
R2_ACCESS_KEY_IDR2_SECRET_ACCESS_KEYRESEND_API_KEY
Plain-Text Vars
R2_ACCOUNT_IDRESEND_FROM_EMAILADMIN_EMAILS
Database
The D1 schema is defined in schema.sql and includes:
usersmagic_linkssessionsapi_keysapi_key_usage_windows
Upload Notes
See these repo docs for integration details:
SKILL.mdSITE_UPLOAD_DESIGN.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
For site publishing:
- use root
index.htmlwhen you want the subdomain root to render a page - if you upload a single wrapper folder such as
my-site/..., OkFile stripsmy-site/automatically - if no root
index.htmlexists, users land on a browsable directory listing instead of downloading an arbitrary file
Articles
Published and outward-facing articles are archived in docs/:
- docs/README.md
- docs/devto-agent-delivery-publish-file-or-site-test-guide.md
- docs/aliyun-workbuddy-agent-file-site-publish-test-guide.md
Contributing
Please read CONTRIBUTING.md before opening pull requests.
Security
Please read SECURITY.md for reporting instructions and secret-handling rules.
Changelog
See CHANGELOG.md for release notes tracked in-repo.
License
Apache-2.0
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file okfile-1.2.0.tar.gz.
File metadata
- Download URL: okfile-1.2.0.tar.gz
- Upload date:
- Size: 13.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.14.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
3a09876e5d817c9b2d4b388c0746e8d1ccba830650c548d50ec97b5f384b6ba9
|
|
| MD5 |
942d6d179738785e3e1be054c7ec90e1
|
|
| BLAKE2b-256 |
89488d50b4d495efe73ebab088f4124ea8da8cfb9410ef5c19e4a46614b12373
|
File details
Details for the file okfile-1.2.0-py3-none-any.whl.
File metadata
- Download URL: okfile-1.2.0-py3-none-any.whl
- Upload date:
- Size: 13.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.14.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f513bfc632482db8b6dced2514f635d31f2a139fc75979f799d9e093775524bc
|
|
| MD5 |
a13abaa7cd6396b0c1a9240a7d37a0bf
|
|
| BLAKE2b-256 |
7f4b184ccef380a028d24a53121ad513639ed7f8f8579bd9f5176a9b57afdc74
|