Connect Your Own Cloudflare R2 Storage to Fileflare

This method allows you to connect your own storage server to Fileflare so that you are in control of your own storage and bandwidth. Doing this allows you to pay for your own storage via your Cloudflare account.

Cloudflare also doesn’t charge for bandwidth usage, so you can deliver many terabytes to your customers at no extra cost.

Video tutorial

Explanation of settings

The below are settings available in the S3 settings page in Fileflare.

image

Use path style endpoint

This feature is only used for legacy compatibility; older S3 clients and tools may default to or require path-style endpoints. This refers to the way requests are structured when accessing S3 buckets and objects. With path-style endpoints, the bucket name is included in the path portion of the URL. In contrast, virtual-hosted style endpoints include the bucket name as part of the domain name (as a subdomain).

Delete files in S3 when removed from the App?

Enabling this setting will delete the files from your S3 bucket when you delete the files inside the Fileflare user interface.

Rename my files to keep their name unique?

Enabling this setting ensures that all files uploaded via the Fileflare uploader are renamed using the UUID4 format when stored in your S3 bucket, eliminating the risk of overwriting existing files with the same name in the bucket. While the UUID4 format is used exclusively within the bucket, the original filenames are retained in Fileflare’s system for display in the app interface and for file delivery to your customers.

If this setting is disabled, files uploaded with duplicate filenames will overwrite existing files in the S3 bucket. Note that UUID4 filenames cannot be reverted to their original names within the bucket.

How to set up

1. Sign up to Cloudflare R2

All you need to do is:

  1. Go to Cloudflare.com
  2. In the left navigation, go to “R2”
  3. Add your payment details
r2

2. Create a bucket

cloudflare

3. Specify jurisdiction

We will want to specify a jurisdiction so that we know what the “Region” is. We will need to enter this into Fileflare later in this tutorial. Just remember where you set it to.

In this guide, we are using the EU.

specify jurisdiction

Click “Create bucket” once you have set it.

4. In your bucket, click Settings

Go to your “Settings” for the bucket. Here is where we are going to paste some things into Fileflare.

setting

4.1 Domain

Do not add a custom domain. Cloudflare does not permit passing the filename through the header with a custom domain.

Enable the access for R2.dev subdomain.

click allow

4.2 Copy the URL from “Bucket details”

Copy the URL without the bucket name so that we can paste it to Fileflare in the “Endpoint” box.

url

Go to Fileflare > Settings > Configure custom S3. Paste the URL to Fileflare’s “Endpoint” box (without the bucket name at the end of the URL).

custom s3
Screenshot 2023 09 22 at 09.22.15 1

4.3 Copy and paste the CORS text from Fileflare to Cloudflare

Go back to Fileflare’s custom S3 settings page and copy the below code.

cors text

Go to the Cloudflare bucket settings page again. Scroll down until you see the CORS setting. Click on the “Add CORS policy” button.

cors policy

Paste the CORS text you copied from Fileflare to this box and overwrite the text there and save.

cors paste

3. Create the API keys

Go to the Overview page and click “Manage R2 API Tokens”.

r2 page

Create API token.

create api token

Make sure you choose “Admin Read & Write”. This is important.

admin read & write

Click the “Create API Token” button to create it.

All you need is the Access Key ID and the Secret Access Key. Copy them to the Fileflare page in the correct boxes.

api key
dda

7. In Fileflare, fill out the final details

In the “Bucket” box, enter your bucket name.

In the “Region” box, enter the region that you selected when creating the bucket. Use the code in the left column in the table below.

Region text to enter into the “Region” boxRegion
wnamWestern North America
enamEastern North America
weurWestern Europe
eeurEastern Europe
apacAsia-Pacific

Because we chosen Eastern EU, we entered “eeur”.

box

Leave the “Folder” box as it is.

Adjust the checkboxes to suit your needs. We would recommend these settings in the image below.

settings

8. Done

Now click “Save”, and all should be done.