❤️ Please support us by using the netcup discount code on the homepage.👉 Get it on the homepage
🤔Lee SRE
Opensource

Upload images to Cloudflare R2 with uPic

Upload images to Cloudflare R2 with uPic

Since uPic hasn't been updated for several years, I decided to use uPic's custom uploader feature to implement custom upload interfaces in order to add other image hosting services. You can easily add any image hosting service you want.

Cloudflare R2

You can upload images to Cloudflare R2 via uPic, using your own domain name.

Create New Bucket

  1. Go to Cloudflare Dashboard
  2. Click "R2 Object Storage" => "+Create bucket"
  3. Set Bucket name, the other options can be left as default
  4. Click "Create bucket"
  5. Settings => Public access => Custom Domains
  6. Click "Connect Domain" and set your domain, e.g., img.example.com

Get Access Key

R2 Object Storage => " API" Button => "Use R2 with APIs" => "Create an API token"

Permissions Should be "Object Read & Write", and the others you could remain to default. Create API Token

Copy the API Keys for the subsequent configuration.

  • Access Key ID
  • Secret Access Key
  • Use jurisdiction-specific endpoints for S3 clients, typically https://<AccountID>.r2.cloudflarestorage.com

Configure uPic

First Step: Add Custom Uploaders

  • Preferences > Click "+" to add a Custom Uploaders

into uPic Custom Uploader Configuration.

uPic Custom Uploader Settings

FieldValueDescription
API URLhttps://upic.netcup.gifts/cloudflare-r2API URL
File Fieldfile
URL Path[data]
Domainhttps://img.example.comYour domain, starts with https:// e.g.,https://img.example.com
Save Keyblog/{year}{month}/{filename}{.suffix}The path you want to set

Second Step: Add other fields Add other fields

Header FieldCloudFlare NameExample Value
bucketBucket Namenetcup
accessKeyIdAccess Key ID6713dae**********7b62ec
secretAccessKeySecret Access Key1ca5d39b***********bcc
endpointUse jurisdiction-specific endpoints for S3 clientshttps://d8a6e1ec6********9c358e1eb.r2.cloudflarestorage.com
filename{saveKey}

Click Validate, and if configured correctly, you'll see a URL in your clipboard. When opened, it should display the uPic icon:

uPic

This means the configuration is successful! 🎉

On this page