Connect Opndrive to Cloudflare R2
R2 speaks the S3 API, so Opndrive works with it directly. You will need your account ID for the endpoint, since R2 addresses buckets per account rather than per region.
Provider
SelectedAdd credentials
Open your drive
Setting up Cloudflare R2Required
1. Allow this site in CORS
In the Cloudflare dashboard, go to R2 object storage and choose your bucket. Open Settings, and under CORS Policy choose Add CORS policy. Paste the policy below into the JSON tab and choose Save. A change can take up to 30 seconds to apply.
2. Paste this policy
[
{
"AllowedHeaders": [
"amz-sdk-invocation-id",
"amz-sdk-request",
"authorization",
"cache-control",
"content-disposition",
"content-encoding",
"content-type",
"expires",
"x-amz-checksum-crc32",
"x-amz-content-sha256",
"x-amz-copy-source",
"x-amz-copy-source-if-match",
"x-amz-copy-source-range",
"x-amz-date",
"x-amz-sdk-checksum-algorithm",
"x-amz-storage-class",
"x-amz-tagging",
"x-amz-user-agent"
],
"AllowedMethods": [
"GET",
"PUT",
"POST",
"DELETE",
"HEAD"
],
"AllowedOrigins": [
"https://opndrive.app"
],
"ExposeHeaders": [
"ETag"
],
"MaxAgeSeconds": 3600
}
]Filled in with the address this page is open at, https://opndrive.app. If you also open Opndrive from another address, add that one too.
3. Permissions the key needs
- Read
- Write
- Delete
- List
4. Clean up interrupted uploads
Large files go up in parts. If an upload stops part way, the parts already sent stay in the bucket: billed, and missing from every listing. Opndrive removes them when an upload fails or is cancelled and it can still reach your bucket, but a closed tab or a dropped connection gives it no chance. A lifecycle rule that deletes incomplete multipart uploads after a few days takes care of the rest. How to add the rule
Worth knowing
The region is almost always "auto". The endpoint contains your account ID, not a region, so copy it from the R2 bucket settings page.
If it fails
What each message Opndrive shows means when connecting to Cloudflare R2, and the fix.
“Could not reach your storage”
No answer came back. Open the browser's developer console (F12): a line saying the request “has been blocked by CORS policy” and “No 'Access-Control-Allow-Origin' header is present” means the bucket does not allow this site yet: apply the CORS policy from the setup steps above. With no such line, check the endpoint address and your connection.
“Those keys were rejected”
Your provider did not accept the key.
InvalidAccessKeyIdmeans the access key ID does not exist;SignatureDoesNotMatchmeans the secret does not belong to it. Check both for typos and stray spaces, and that the key has not been deleted.AuthorizationHeaderMalformedis filed here too, but on Amazon S3 it means the region does not match the bucket's, so check the region before the keys.Shown for the error codesInvalidAccessKeyId,SignatureDoesNotMatch,InvalidClientTokenId,UnrecognizedClientException,AuthorizationHeaderMalformed,TokenRefreshRequired,ExpiredToken, and for any other error answered with HTTP status 401.“That bucket was not found”
NoSuchBucketmeans no bucket has that name.PermanentRedirectmeans it exists but has to be reached through a different endpoint, which usually means the region is wrong.Shown for the error codesNoSuchBucket,PermanentRedirect,AuthorizationQueryParameters, and for any other error answered with HTTP status 404.“These keys are not allowed to do that”
AccessDenied: the provider knows the key, but its policy does not allow the request. Give it the permissions in step 3, on this bucket.Shown for the error codesAccessDenied,AllAccessDisabled,AccountProblem, and for any other error answered with HTTP status 403.“Something went wrong reaching your storage”
Your provider answered with an error Opndrive does not recognise, such as a server error. Trying again is worth a go; if it keeps happening, the browser console has the request and the provider's own message.
Large uploads fail or keep retrying at the end, while small files upload
Bigger files go up in parts, and finishing the upload needs each part's
ETag, which the browser hides unless the CORS policy exposes it. Make sureETagis in the exposed headers, as it is in the policy above.
Particular to Cloudflare R2
- Use the S3 API endpoint, https://<account-id>.r2.cloudflarestorage.com. Cloudflare documents that signed requests, which is everything Opndrive sends, work on that domain and not on a custom domain set up for public access.