Upload to Cloudflare R2
Cloudflare R2 is S3-compatible, so ScreenshotOne uploads screenshots, rendered HTML, PDFs, and videos to it the same way it does to Amazon S3. You need four values:
| ScreenshotOne field | Where to find it in Cloudflare |
|---|---|
| Endpoint URL | https://<ACCOUNT_ID>.r2.cloudflarestorage.com |
| Access key ID | Shown once after you create an R2 API token, as “Access Key ID” |
| Secret key | Shown once after you create an R2 API token, as “Secret Access Key” |
| Default bucket | The name of your R2 bucket |
Cloudflare’s dashboard changes from time to time, so the names of menus might be a bit different from what you see, but the steps stay the same.
Create a bucket
Section titled “Create a bucket”If you don’t have a bucket yet, open R2 object storage in the Cloudflare dashboard and create one. Remember its name. You will need it as the default bucket.
Create an R2 API token
Section titled “Create an R2 API token”R2 uses its own API tokens. A regular Cloudflare API token from your profile doesn’t work for uploads.
- In the Cloudflare dashboard, go to R2 object storage, then Overview.
- Under Account Details, select Manage next to API Tokens.
- Choose Create Account API token (or Create User API token if you prefer a token tied to your user).
- Under Permissions, choose Object Read & Write.
- Optionally, limit the token to the bucket you use for screenshots. We recommend it.
- Create the token.
The next screen shows several values. Copy these two:
- Access Key ID. It goes to the “Access key ID” field in ScreenshotOne.
- Secret Access Key. It goes to the “Secret key” field in ScreenshotOne.
ScreenshotOne needs Object Read & Write, not only write: testing the configuration uploads a small test file and then deletes it.
Find the endpoint
Section titled “Find the endpoint”The endpoint is https://<ACCOUNT_ID>.r2.cloudflarestorage.com, where <ACCOUNT_ID> is your Cloudflare account ID. You can find the account ID in Account Details on the R2 overview page.
You can also copy the endpoint from your bucket’s settings, where Cloudflare shows it as the “S3 API” URL. That URL ends with the bucket name, like https://<ACCOUNT_ID>.r2.cloudflarestorage.com/my-bucket. Remove /my-bucket from the end and put the bucket name in the “Default bucket” field instead.
If you created the bucket with a jurisdiction, use the jurisdiction’s endpoint:
- European Union:
https://<ACCOUNT_ID>.eu.r2.cloudflarestorage.com - FedRAMP:
https://<ACCOUNT_ID>.fedramp.r2.cloudflarestorage.com
You don’t need to specify a region.
Configure R2 in ScreenshotOne
Section titled “Configure R2 in ScreenshotOne”Open the S3 integration page in the dashboard and fill in the form:
- Endpoint URL:
https://<ACCOUNT_ID>.r2.cloudflarestorage.com. - Access key ID: the Access Key ID from the token.
- Secret key: the Secret Access Key from the token.
- Default bucket: your bucket name.
Click Test configuration. If the test passes, click Save configuration.
You can also skip the dashboard and pass the credentials in every API request with storage_endpoint, storage_access_key_id, storage_secret_access_key, and storage_bucket.
Upload a screenshot
Section titled “Upload a screenshot”Add store=true and storage_path to your request. The file extension is added automatically based on the format:
https://api.screenshotone.com/take?access_key=<access key>&url=https://example.com&store=true&storage_path=screenshots/exampleThe screenshot is uploaded to screenshots/example.jpg in your default bucket. Add response_type=empty if you don’t need the screenshot in the response.
All storage options, including asynchronous uploads with webhooks, work the same as for Amazon S3. Read the S3 guide for more examples.
Differences from Amazon S3
Section titled “Differences from Amazon S3”- ACLs: R2 doesn’t support object ACLs, so don’t set storage_acl. Files in an R2 bucket are private by default. To serve them publicly, enable public access for the bucket in its Cloudflare settings, with a custom domain or the
r2.devURL. - Storage class: R2 supports only
standard(the default) andstandard_iafor storage_class. - File location: storage_return_location returns the location on the R2 S3 API endpoint, which isn’t publicly accessible. If you serve files from a public domain, build the public URL from your domain and the storage path.
Troubleshooting
Section titled “Troubleshooting”- “Access was denied”: check that you used the Access Key ID and the Secret Access Key, not the token value, and that the token has Object Read & Write permission for this bucket.
- “Failed to resolve the endpoint hostname”: check the account ID in the endpoint. If you just created the bucket, wait a few minutes and try again.
If something still doesn’t work, write to us at support@screenshotone.com with the error message you see.