Hetzner Object Storage
Hetzner Object Storage via the S3-compatible API. Endpoint derived from the location code (fsn1, nbg1, hel1).
Installation
@aws-sdk/client-s3, @aws-sdk/s3-presigned-post, and @aws-sdk/s3-request-presigner are optional peer dependencies of files-sdk - install alongside the SDK so the adapter’s imports resolve at runtime.
npm install files-sdk @aws-sdk/client-s3 @aws-sdk/s3-presigned-post @aws-sdk/s3-request-presignerpnpm add files-sdk @aws-sdk/client-s3 @aws-sdk/s3-presigned-post @aws-sdk/s3-request-presigneryarn add files-sdk @aws-sdk/client-s3 @aws-sdk/s3-presigned-post @aws-sdk/s3-request-presignerbun add files-sdk @aws-sdk/client-s3 @aws-sdk/s3-presigned-post @aws-sdk/s3-request-presignerUsage
import { Files } from "files-sdk";
import { hetzner } from "files-sdk/hetzner";
const files = new Files({
adapter: hetzner({
bucket: "uploads",
region: "fsn1", // or "nbg1", "hel1"
// accessKeyId / secretAccessKey auto-loaded from
// HCLOUD_ACCESS_KEY_ID / HCLOUD_SECRET_ACCESS_KEY
}),
});
Options
bucketstring
Hetzner bucket name. The adapter scopes all operations to it.
stringregionstring
Hetzner Object Storage location code, e.g. `"fsn1"` (Falkenstein), `"nbg1"` (Nuremberg), `"hel1"` (Helsinki). Drives the endpoint host; there's no env-var fallback. Doubles as the SigV4 region — Hetzner ignores it for routing but the signature requires *some* value.
stringendpoint?string
Override the Hetzner endpoint. When unset, defaults to `https://${region}.your-objectstorage.com`. Hetzner routes by Host header — the SDK prepends the bucket subdomain for virtual-hosted style.
stringaccessKeyId?string
Static credentials. Falls back to `HCLOUD_ACCESS_KEY_ID`; required if that env var isn't set.
stringsecretAccessKey?string
Static credentials. Falls back to `HCLOUD_SECRET_ACCESS_KEY`; required if that env var isn't set.
stringforcePathStyle?boolean
Use path-style addressing (`/<bucket>/<key>`) rather than virtual-hosted style. Defaults to `false` — virtual-hosted is canonical for Hetzner.
booleanpublicBaseUrl?string
Origin used to build URLs from `url()`. When set, `url(key)` returns `${publicBaseUrl}/${key}` and skips signing — typical values are a custom CNAME or reverse proxy fronting the bucket. Hetzner Object Storage has no built-in CDN, so leaving this unset is the common case. When unset, `url()` falls back to a presigned GetObject (default expiry: 1 hour).
stringdefaultUrlExpiresIn?number
Default expiry, in seconds, for the presigned URLs returned by `url()` when `publicBaseUrl` is not set. Defaults to 3600 (1 hour).
numberCompatibility
| Method | Status | Notes |
|---|---|---|
upload |
✅ | |
download |
✅ | |
delete |
✅ | |
list |
✅ | |
search |
✅ | |
head |
✅ | |
exists |
✅ | |
copy |
✅ | |
url |
✅ | |
signedUploadUrl |
✅ |