Cloudflare Pages + R2 file library with public browsing and scoped admin uploads.
- Public file browsing and downloads
- R2-backed uploads, folders, rename, delete, copy, and move
- Large file multipart uploads
- Image/video/PDF thumbnails
- Multiple admin accounts with per-directory write permissions
- Connect this repository to Cloudflare Pages.
- Set the build command to
npm run build. - Set the build output directory to
build. - Add environment variables:
| Variable name | Value |
|---|---|
PUBURL |
Public R2 bucket URL, for example https://pub-xxxx.r2.dev |
admin:123456 |
* |
user1:123456 |
user1/ |
The admin variable name is username:password. The value is the directory the
account can write to. Use * for full write access. Multiple directories can be
separated with commas, semicolons, or new lines.
If Cloudflare rejects : in variable names, use one variable named FD_ADMINS
instead:
admin:123456=*
user1:123456=user1/
- Start the first deployment.
- Bind the R2 bucket to the Pages project with binding name
BUCKET. - Redeploy so the
BUCKETbinding is available to Pages Functions.
Open the deployed site to browse files publicly. Use the top-right menu to sign
in before uploading, creating folders, renaming, or deleting files. A scoped
account can only write inside its configured directory; for example
user1:123456 = user1/ can create and modify files under user1/.
npm run devThe dev script builds the React app and starts Cloudflare Pages Functions with a
local R2 binding named BUCKET. For local admin accounts, create .dev.vars
and prefer FD_ADMINS:
PUBURL=
FD_ADMINS="admin:123456=*
user1:123456=user1/"
The original WebDAV endpoint has been removed. The web app now uses Pages
Functions under /api/*.