{"id":22202649,"url":"https://github.com/cherry/sharex-r2-cloudflare-workers","last_synced_at":"2025-04-05T22:06:20.610Z","repository":{"id":39987045,"uuid":"480533232","full_name":"Cherry/ShareX-R2-Cloudflare-Workers","owner":"Cherry","description":"Custom ShareX Uploader to Cloudflare R2 via Workers","archived":false,"fork":false,"pushed_at":"2025-03-02T14:56:00.000Z","size":859,"stargazers_count":89,"open_issues_count":0,"forks_count":28,"subscribers_count":3,"default_branch":"main","last_synced_at":"2025-03-29T21:08:49.795Z","etag":null,"topics":["cloudflare-r2","cloudflare-workers","sharex-uploader"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Cherry.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","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},"funding":{"github":"cherry","custom":"https://www.paypal.me/jamesross134"}},"created_at":"2022-04-11T20:02:39.000Z","updated_at":"2025-03-18T02:57:51.000Z","dependencies_parsed_at":"2023-10-16T06:37:28.799Z","dependency_job_id":"130f0f2e-aa50-4ad1-a262-31c4e7778daf","html_url":"https://github.com/Cherry/ShareX-R2-Cloudflare-Workers","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Cherry%2FShareX-R2-Cloudflare-Workers","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Cherry%2FShareX-R2-Cloudflare-Workers/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Cherry%2FShareX-R2-Cloudflare-Workers/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Cherry%2FShareX-R2-Cloudflare-Workers/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Cherry","download_url":"https://codeload.github.com/Cherry/ShareX-R2-Cloudflare-Workers/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247406087,"owners_count":20933803,"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","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":["cloudflare-r2","cloudflare-workers","sharex-uploader"],"created_at":"2024-12-02T16:35:39.412Z","updated_at":"2025-04-05T22:06:20.574Z","avatar_url":"https://github.com/Cherry.png","language":"TypeScript","funding_links":["https://github.com/sponsors/cherry","https://www.paypal.me/jamesross134"],"categories":[],"sub_categories":[],"readme":"# ShareX-R2-Cloudflare-Workers\n\nThis repo pairs with the blog post found at https://jross.me/cloudflare-r2-sharex-custom-uploader. It assumes some precursory knowledge about Workers, Cloudflare, and ShareX. If you have any questions, please feel free to create a discussion/issue, or submit a PR with any docs improvements! I want to extend this repo in the future and when R2 is more widely available, and document the process from start to finish.\n\n\n## Video Guide\n\nFor a video walkthrough on how to set everything up, including the Worker, R2, and ShareX, you can follow this great guide from [KianNH](https://github.com/KianNH).\n\nhttps://watch.videodelivery.net/3fb9e86deffbd4351b9187db92136ef5\n\n\n## Worker and R2 Setup\n\n- Ensure you have wrangler installed and configured. See [here](https://developers.cloudflare.com/workers/get-started/guide/) for more details\n- Clone repo (or fork?), and run `npm ci` to install dependencies\n- Choose a bucket name to use in the next steps. For the purpose of this example, I'll be using `sharex-files`\n- Edit `wrangler.toml` with your `account_id`, `route`, and `r2_buckets.bucket_name`\n- Run `wrangler r2 bucket create \u003cbucket name\u003e`\n- Generate a random string of characters - this will be used for an `AUTH_KEY` header that we'll send along with ShareX\n\t- This ensures that only you can upload to your script\n- In your GitHub repository, create an `AUTH_KEY` secret, and set its value to the `AUTH_KEY` you just generated\n\t- This will be used by the GitHub Action to deploy the worker\n- In your GitHub repository, create a `CF_API_TOKEN` secret, and set its value to a Cloudflare API token with the following permissions:\n\t- Account - Workers R2 Storage - Edit\n\t- Account - Workers Tail - Read\n\t- Account - Workers KV Storage - Edit\n\t- Account - Workers Scripts - Edit\n\t- Account - Account Settings - Read\n\t- User - User Details - Read\n\t- Zone - Workers Routes - Edit\n\n\t- Then be sure to give it access to the application account/zone resources you want to use\n![Cloudflare API token for Wrangler R2 access](https://r2-sharex.jross.me/file/2022/03/f8a40b17-9005-4645-9fdb-1803085308d0.png)\n\n- If using GitHub Actions (like this repo), simply push your changes and the worker will be automatically deployed - see your Actions log for any errors.\n- (optional) If you want to deploy manually, or use some other CI other than GitHub Actions, you will need to manually setup the `AUTH_KEY` secret (via the Workers UI, or `wrangler secret put`), and then run `npm run deploy`.\n\n\n## ShareX Setup\n\nFor full documentation on ShareX custom uploaders, please review their documentation at https://getsharex.com/docs/custom-uploader.\n\n- Open Main Window -\u003e Destinations -\u003e Custom Uploader Settings\n- New -\u003e Name it `R2` or whatever else you want\n- Set the `Destination Type` to `Image uploadere`\n- Set the `Method` to `POST`\n- Set the `Request URL` to the URL of your worker, with `/upload` appended, such as `https://r2-sharex.jross.me/upload`\n- Set the `Body` to `Binary`\n- Leave URL paramaters blank\n- (optional) Add a new URL paramater called `filename`, and set it to `{filename}`. If this is set, the original filename will be used when storing to R2, otherwise a random ID will be generated\n- Add a new header under `Headers` called `x-auth-key`, and set it to the secure string you generated earlier\n- Set `URL` to `{json:image}`\n- Set `Deletion URL` to `{json:deleteUrl}`\n- Use the testers on the left hand side to test your configuration\n- When ready, change your default destination for images (etc.) to `R2`\n\n![ShareX configuration for a custom Cloudflare R2 Uploader](./.github/sharex-config.png)\n\n## Acknowledgements\n\nhttps://github.com/kotx/render is used to retrieve files from R2, since this is a fantastic example handling ranges, etags, HEAD requests, and more. Huge shoutout to [kotx](https://github.com/kotx) for this work!\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcherry%2Fsharex-r2-cloudflare-workers","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcherry%2Fsharex-r2-cloudflare-workers","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcherry%2Fsharex-r2-cloudflare-workers/lists"}