glitternetwork/pinme/pinme-r2
- community
Checking that the SKILL.md file is still in the repository.
Use when a PinMe Cloudflare Worker needs R2 object storage, including secure file or image upload, streaming download, metadata lookup, deletion, listing, Range requests, or R2+D1 coordination. Guides AI to use PinMe's automatically injected env.R2 binding without R2 credentials or manual Wrangler configuration.
Install
npx vskill@latest install glitternetwork/pinme/pinme-r2SKILL.md
PinMe Worker R2 Storage
Use the project-scoped R2 bucket that PinMe binds to every deployed Worker as env.R2. Do not create credentials, choose a bucket name, or edit generated Wrangler configuration.
Runtime Contract
PinMe rebuilds trusted Worker metadata on create, save, and update. Client metadata cannot replace the R2 binding.
| Binding | TypeScript type | Availability | |
|---|---|---|---|
DB | D1Database | Always injected | |
R2 | R2Bucket | Always injected; current project's bucket | |
API_KEY | string | Always injected | |
LLM_API_KEY | string | Always injected | |
BASE_URL | string | Always injected | |
WORKER_URL | string | Always injected | |
PROJECT_NAME | string | Always injected |
Payment-specific bindings such as UNIWEB_SECRET are conditional and unrelated to R2 access.
Declare only the bindings used by the Worker module. R2 code normally starts with:
When the same module coordinates file metadata in D1, also declare DB: D1Database as a required field.
Choose R2 or D1
- Use R2 for file bodies, images, attachments, media, exports, and other objects addressed by key.
- Use D1 for searchable business metadata, ownership, relations, status, and audit fields.
- For managed files, store the body in R2 and store only its key and business metadata in D1.
- Never use Worker local filesystem state for persistence and never store complete files or base64 payloads in D1.
Required Security Workflow
Apply this sequence to every upload, download, metadata, delete, and list route:
Use the application's existing authentication. The examples below accept a trusted userId that the route must obtain from verified identity claims, never from an untrusted request body or query parameter.
Keep object keys server-controlled. Prefer opaque IDs under an owner prefix:
Never accept a complete object key from the client. Reject empty identifiers, . or .. segments, backslashes, control characters, and any attempt to access another user's prefix.
Shared Helpers
Use small helpers and explicit business limits. Adapt the allowlist to the product rather than accepting every client-supplied media type.
Client filenames and Content-Type are hints, not proof of content. For sensitive formats, inspect magic bytes or send the object through an asynchronous validation/scanning workflow before marking it ready.
Stream an Upload
Require authentication before calling this handler. Pass request.body directly to R2; do not call arrayBuffer(), text(), json(), formData(), or base64 conversion first.
Do not return the bucket name or internal object-key layout. Return an opaque file ID that later routes resolve under the authenticated owner's prefix.
Stream a Download
Validate a single Range header before passing it to R2. R2 may return null when the object does not exist, or metadata without a body when a conditional request fails.
For routes backed by D1 metadata, authorize the D1 row's owner before calling env.R2.get. Do not infer ownership only from a client-provided path.
Read Metadata with HEAD
Use head() when only size, ETag, upload time, or metadata is needed. Do not download the body to answer metadata requests.
Delete an Object
R2 can delete up to 1000 keys in one delete([...keys]) call. Batch deletion must still derive and authorize every key server-side.
List an Owner's Objects
Never list the whole bucket for an end-user request. Derive the prefix from verified identity and treat the cursor as opaque.
An R2 list call returns at most 1000 entries and may return fewer than the requested limit when metadata is included. Continue only when page.truncated is true; never use objects.length === limit as the pagination condition.
Route and Error Semantics
Authenticate once in the router, derive a trusted userId, then pass it to the handlers. Return an Allow header for unsupported methods.
| Status | Meaning | |
|---|---|---|
| 400 | Invalid file ID, body, cursor, or media type | |
| 401 | Missing or invalid authentication | |
| 403 | Authenticated but not allowed to access the object | |
| 404 | Object or owned metadata record not found | |
| 411 | A capped upload route requires Content-Length but it is absent | |
| 412 | Conditional R2 operation failed | |
| 413 | Business or platform upload limit exceeded | |
| 416 | Invalid or unsatisfiable Range request | |
| 500 | Sanitized internal storage failure |
Catch storage failures at the route boundary, log only non-sensitive context, and return a generic error. Never return a raw provider error, bucket name, credential, or internal object key. Translate a valid-but-unsatisfiable R2 Range failure to 416 without returning the provider error text.
Coordinate R2 with D1
R2 and D1 do not share a transaction. Use an explicit state transition when business metadata is required:
- If upload fails, delete the pending row or mark it failed.
- If the final D1 update fails, delete the newly uploaded object or retain a durable pending state for a compensation job.
- Store at least: public file ID, internal object key, owner ID, original name, size, MIME, status, and timestamps.
- For download and delete, load the row by public file ID and owner ID before touching R2.
- Delete the R2 object and D1 row with an explicit retry/compensation policy; do not pretend the two operations are atomic.
Large Files
Use request.body → env.R2.put for small and medium uploads. Streaming avoids Worker memory amplification but does not bypass the Cloudflare request-body limit for the account plan.
This is the start of the file. Read the full SKILL.md on GitHub.
Security
- Security scanPassed, 95 of 100Pattern checks on the skill's files.
- Model reviewPassed
Quality evaluation
- Task evaluationNot runNo evaluation yet. Run one in Skill Studio.
Source
- SKILL.md in the repositoryCheckingskills/pinme-r2/SKILL.md
Popularity
- 7-day trend score
- 0
Not refreshed yet.
Works with
Any agent vskill installs to: 56 targets in all. These 39 have a page on this site.
- Claude Code
- Cursor
- GitHub Copilot
- Windsurf
- Codex
- Gemini CLI
- Cline
- Amp
- Roo Code
- Goose
- Continue
- Kilo Code
- Junie
- Trae
- OpenHands
- Qwen Code
- AI Agent
- Tabnine Chat
- Sourcegraph Cody
- Amazon Q
- Firebase Genkit
- Sweep
- Devin
- Phind
- Mentat
- Claude Desktop
- Aider
- GPT Pilot
- Plandex
- bolt.new
- v0
- Replit Agent
- Anse
- TypingMind
- BetterChatGPT
- LibreChat
- Warp AI
- Pieces
- Fig AI
Embed badge
[](https://verified-skill.com/skills/glitternetwork/pinme/pinme-r2)