Connect Opndrive to Backblaze B2

B2 offers an S3-compatible endpoint alongside its native API, and Opndrive uses the former. Create an application key scoped to the bucket you want to browse.

Step 1, complete

Provider

Selected
Backblaze B2Low-cost cloud storageChange
2, current step

Add credentials

secret access key is hidden

Defaults to https://s3.us-west-002.backblazeb2.com

How this connection is listed when you switch between them. Left blank, it is called “Backblaze B2”.

Fill in the key, secret and bucket

3, not started

Open your drive

Setting up Backblaze B2Required

1. Allow this site in CORS

Set the rules through the B2 S3-compatible API, which takes them in the same format as Amazon S3. Configure the AWS CLI with your B2 application key ID and key, save the policy below as cors.json, and run the command under it with your bucket name and region filled in.

2. Save this as cors.json

{
  "CORSRules": [
    {
      "AllowedHeaders": [
        "*"
      ],
      "AllowedMethods": [
        "GET",
        "PUT",
        "POST",
        "DELETE",
        "HEAD"
      ],
      "AllowedOrigins": [
        "https://opndrive.app"
      ],
      "ExposeHeaders": [
        "ETag"
      ],
      "MaxAgeSeconds": 3600
    }
  ]
}

Then apply it:

aws s3api put-bucket-cors --bucket YOUR_BUCKET --cors-configuration file://cors.json --endpoint-url https://s3.YOUR_REGION.backblazeb2.com

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

  • listFiles
  • readFiles
  • writeFiles
  • deleteFiles

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

Backblaze's own CORS rule format covers S3 GET, HEAD, PUT and DELETE but has no operation for POST, which multipart uploads and deleting several files at once need. That is why the rules go in through the S3 API here. If the bucket already has rules from the native API - set with the b2 command-line tool, as Opndrive's setup steps used to say - the S3 API cannot change them: Backblaze says they can only be changed through the native API (b2 bucket update --cors-rules). Remove them there first, then run the command above.

Backblaze B2 CORS rules documentation

If it fails

What each message Opndrive shows means when connecting to Backblaze B2, 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. InvalidAccessKeyId means the access key ID does not exist; SignatureDoesNotMatch means the secret does not belong to it. Check both for typos and stray spaces, and that the key has not been deleted. AuthorizationHeaderMalformed is 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 codes InvalidAccessKeyId, SignatureDoesNotMatch, InvalidClientTokenId, UnrecognizedClientException, AuthorizationHeaderMalformed, TokenRefreshRequired, ExpiredToken, and for any other error answered with HTTP status 401.

  • “That bucket was not found”

    NoSuchBucket means no bucket has that name. PermanentRedirect means it exists but has to be reached through a different endpoint, which usually means the region is wrong.Shown for the error codes NoSuchBucket, 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 codes AccessDenied, 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 sure ETag is in the exposed headers, as it is in the policy above.

Particular to Backblaze B2

  • Small files upload but large ones, or deleting several files at once, fail with "Could not reach your storage": the rules are probably in Backblaze's own format, which cannot allow the POST requests those use. Remove those through the native API, as the setup steps above say, and apply the policy above through the S3 API instead.
Every connection error, explained