Logo
← Back to blog

How to connect Hetzner Object Storage to file.rocks

Cover image

Hetzner Object Storage speaks the same API as Amazon S3, so file.rocks connects to it with the Other S3-compatible option. Your files stay in your Hetzner bucket, and file.rocks gives you a place to browse and upload them.

You'll set up two things at Hetzner first: S3 credentials, and a CORS rule so uploads from your browser go through. The credentials take a few clicks in Hetzner Console. The CORS rule needs a terminal, and we'll go through it one command at a time.

1. Find your endpoint

Your endpoint is your bucket's location code followed by .your-objectstorage.com. Hetzner has three:

  • Falkenstein: https://fsn1.your-objectstorage.com
  • Nuremberg: https://nbg1.your-objectstorage.com
  • Helsinki: https://hel1.your-objectstorage.com

Use the location your bucket is in. Paste only that address, without the bucket name in front of it.

2. Create S3 credentials

In Hetzner Console, open your project. Click Security in the left menu, then S3 Credentials in the menu along the top, and select Generate credentials. Type a description you'll recognize, like "file.rocks".

The top box shows your access key and the bottom box shows your secret key. Copy both now. Hetzner won't show the secret key again after you close the window.

By default, these credentials work for every bucket in the project.

3. Allow uploads with CORS

When you upload in file.rocks, the file goes straight from your browser to your bucket. Your bucket has to allow that, and file.rocks doesn't set it up for you.

Hetzner Console handles the basics, like buckets and credentials. Everything else, CORS included, goes through S3 tools. Hetzner's guide uses the AWS CLI, so we will too.

Set up the AWS CLI

Install the AWS CLI using Amazon's install guide. Then open a terminal. On a Mac that's the Terminal app, on Windows it's PowerShell, and on Linux it's whatever terminal you normally use.

Run this and paste your access key and secret key when it asks:

aws configure

When it asks for Default region name, type your location code, like fsn1. You can leave Default output format empty.

Now open the config file it made. On Mac or Linux, run nano ~/.aws/config. On Windows, the file is .aws\config in your user folder.

Make it look like this, which is Hetzner's example with a region line added, and put your own location in place of fsn1.

[default]
region = fsn1
endpoint_url = https://fsn1.your-objectstorage.com
#Keep the lines below commented out when you create Buckets
#Uncomment the lines below before you create presigned URLs
#s3 =
#  addressing_style = virtual

Leave the last four lines starting with # just as they are. Save the file. In nano, that's Ctrl + O, then Enter, then Ctrl + X.

Write the CORS rule

Make a file called file-rocks-cors.json with this in it:

{
  "CORSRules": [
    {
      "AllowedOrigins": ["https://www.file.rocks"],
      "AllowedMethods": ["PUT", "GET", "HEAD"],
      "AllowedHeaders": ["Content-Type"]
    }
  ]
}

Hetzner's own example only allows GET and HEAD. file.rocks needs PUT too, because that's how your browser sends the file.

Apply it and check it

In the same folder as the file, run this, with your bucket's name in place of your-bucket:

aws s3api put-bucket-cors --bucket your-bucket --cors-configuration file://file-rocks-cors.json

If it worked, it prints nothing. That's normal. Now read the rule back:

aws s3api get-bucket-cors --bucket your-bucket

You should see your origin, the three methods, and Content-Type. If you already use s3cmd, Hetzner's guide shows the same rule as an XML file applied with s3cmd setcors.

4. Open the bucket form

In file.rocks, go to Settings, then Buckets, and click Add Bucket. If you don't have any buckets yet, the button reads Create your first bucket.

The Create Bucket window opens. Under Storage Type, pick Bring Your Own. Then open Provider and choose Other S3-compatible.

5. Fill in the details

Access Key ID and Secret Access Key are the pair you made in step 2.

Endpoint is the address from step 1, starting with https://.

Bucket Name is the name of your bucket.

For Region, type your location code, like fsn1. That's how Hetzner's own docs fill in the region for S3 tools. If file.rocks puts in something different after you leave the Endpoint or Bucket Name box, change it back.

Nickname (optional) is the name you'll see in file.rocks, like "Hetzner fsn1".

6. Save, then check Files

Click Save Bucket. file.rocks doesn't test an S3-compatible connection when you save, so the bucket saves even if a detail is wrong.

Open Files to check. If the files in your bucket show up, your keys, endpoint and bucket name are right.

If nothing loads, look at these again:

  • The Access Key ID and Secret Access Key
  • The location in the Endpoint
  • The Bucket Name

7. Upload a test file

Drop a small file into Files and see if it lands.

If your files list fine but uploads fail, check the CORS rule from step 3 first. Run get-bucket-cors again and make sure the origin is exactly https://www.file.rocks and PUT is in the list.

For more on uploading, see how to upload files to your own bucket. The DigitalOcean Spaces guide and the MinIO guide walk through other Other S3-compatible setups, and how to connect an Amazon S3 bucket covers S3 itself. If you're still choosing a provider, cheapest cloud object storage compares the options.

Your files stay in the bucket you connected, and file.rocks is how you manage them.

How to connect Hetzner Object Storage to file.rocks | file.rocks Blog