{"id":13618416,"url":"https://github.com/yusukebe/r2-image-worker","last_synced_at":"2025-10-05T15:59:24.215Z","repository":{"id":38691390,"uuid":"491337798","full_name":"yusukebe/r2-image-worker","owner":"yusukebe","description":"Store and Deliver images with R2 backend Cloudflare Workers.","archived":false,"fork":false,"pushed_at":"2025-08-09T20:37:11.000Z","size":68,"stargazers_count":317,"open_issues_count":5,"forks_count":30,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-08-09T20:40:23.179Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/yusukebe.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2022-05-12T02:30:17.000Z","updated_at":"2025-08-09T20:30:04.000Z","dependencies_parsed_at":"2024-01-19T10:58:17.552Z","dependency_job_id":"d1eaa6f9-6274-4655-b169-1946b88eb6cc","html_url":"https://github.com/yusukebe/r2-image-worker","commit_stats":{"total_commits":21,"total_committers":4,"mean_commits":5.25,"dds":0.1428571428571429,"last_synced_commit":"1a174856455adbc26d4fe92d3a248d143d054909"},"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/yusukebe/r2-image-worker","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yusukebe%2Fr2-image-worker","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yusukebe%2Fr2-image-worker/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yusukebe%2Fr2-image-worker/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yusukebe%2Fr2-image-worker/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/yusukebe","download_url":"https://codeload.github.com/yusukebe/r2-image-worker/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yusukebe%2Fr2-image-worker/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":278477815,"owners_count":25993540,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-10-05T02:00:06.059Z","response_time":54,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-08-01T20:02:01.039Z","updated_at":"2025-10-05T15:59:24.210Z","avatar_url":"https://github.com/yusukebe.png","language":"TypeScript","funding_links":[],"categories":["TypeScript"],"sub_categories":[],"readme":"# r2-image-worker\n\nStore and deliver images with Cloudflare R2 backend Cloudflare Workers.\n\n## Synopsis\n\n1. Deploy **r2-image-worker** to Cloudflare Workers.\n2. `PUT` your image file to **r2-image-worker**.\n3. The image file will be stored in Cloudflare R2 storage.\n4. **r2-image-worker** will respond the key of the stored image. `abcdef.png`\n5. **r2-image-worker** serve the images on `https://r2-image-worker.username.workers.dev/abcdef.png`\n6. Images will be cached on Cloudflare CDN.\n\n```plain\nUser =\u003e Image =\u003e r2-image-worker =\u003e R2\nUser \u003c= Image \u003c= r2-image-worker \u003c= CDN Cache \u003c= R2\n```\n\n## Prerequisites\n\n- Cloudflare Account\n- Wrangler CLI\n- _Optional: Custom domain - (Cache API is not available in `.workers.dev` domain)_\n\n## Set up\n\nFirst, `git clone`\n\n```plain\ngit clone https://github.com/yusukebe/r2-image-worker.git\ncd r2-image-worker\n```\n\nCreate R2 bucket:\n\n```plain\nwrangler r2 bucket create images\n```\n\nCopy `wrangler.example.jsonc` to `wrangler.jsonc`:\n\n```plain\ncp wrangler.example.jsonc wrangler.jsonc\n```\n\nEdit `wrangler.jsonc`.\n\n## Variables\n\n### Secret variables\n\nSecret variables are:\n\n- `USER` - User name of basic auth\n- `PASS` - User password of basic auth\n\nTo set these, use `wrangler secret put` command:\n\n```bash\nwrangler secret put USER\n```\n\n## Publish\n\nTo publish to your Cloudflare Workers:\n\n```bash\nnpm run deploy\n```\n\n## Endpoints\n\n### `/upload`\n\nHeader:\n\nTo pass the Basic Auth, add the Base64 string of \"user:pass\" to `Authorization` header.\n\n```plain\nAuthorization: Basic ...\n```\n\nBody:\n\nValue of `body` should be a `Form` contains an image binary and a width and a height.\n\n- image: `File`\n- width: `string` (optional)\n- height: `string` (optional)\n\n### Test\n\n1. Download a simple image\n\n```bash\nwget https://hono.dev/images/hono-kawaii.png -O /tmp/1.jpg\n```\n\n2. Upload to u endpoint.\n\n```bash\ncurl -X PUT \\\n  -F \"image=@/tmp/1.jpg\" \\\n  https://change_user_here:change_pass_here@change_url_here/upload \\\n  -vvv\n```\n\n3. Visit the image\n\n```bash\nhttps://change_user_here:change_pass_here@change_url_here/image_returned_in_step2\n```\n\n## Tips\n\n### Using Cloudflare Images\n\nYou can deliver your images via [Cloudflare Images](https://developers.cloudflare.com/images/) if you are using a custom domain.\n\n```plain\nhttps://\u003cZONE\u003e/cdn-cgi/image/format=auto,width=800,quality=75/\u003cSOURCE-IMAGE\u003e\n```\n\n### Using with Shortcuts\n\nAwesome!!!\n\n![Screen cast](https://github.com/user-attachments/assets/c9239e96-dce9-45ba-aa07-a94aa53b3ba7)\n\nSetting shortcuts like this:\n\n![Screenshot](https://ss.yusukebe.com/cdn-cgi/image/format=auto,quality=90/44136fa355b3678a1146ad16f7e8649e94fb4fc21fe77e8310c060f61caaff8a_1530x2366.png)\n\n## Author\n\nYusuke Wada \u003chttps://github.com/yusukebe\u003e\n\n## License\n\nMIT\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fyusukebe%2Fr2-image-worker","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fyusukebe%2Fr2-image-worker","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fyusukebe%2Fr2-image-worker/lists"}