Skip to content

S3-Compatible Gateway

blobgw-s3 puts an S3-compatible front end on the object gateway. Standard S3 clients such as the AWS CLI, boto3, and aws-sdk-go-v2 get content-defined deduplication and content-type compression on the server side. The gateway maps each bucket to a dedup domain and each object key to a gateway ref.

Supported operations

AreaOperations
ServiceListBuckets (GET /)
BucketsCreateBucket, HeadBucket, DeleteBucket (only when empty), ListObjectsV2 (prefix, delimiter, continuation-token, start-after, max-keys, encoding-type=url), and a minimal marker-based ListObjects v1
ObjectsPutObject, GetObject (including Range requests with 206 and 416), HeadObject, DeleteObject
MultipartCreateMultipartUpload, UploadPart, CompleteMultipartUpload, AbortMultipartUpload, ListParts, ListMultipartUploads
Metadatax-amz-meta-* user metadata and the object ETag are stored durably in the object’s manifest. Multipart objects get the standard composite multipart ETag.

Addressing is path-style only (http://host:port/bucket/key). Anything not listed above, including query-string presigned URLs, isn’t supported by this release.

Authentication

Requests must be signed with AWS Signature Version 4 in the Authorization header. Three payload modes are accepted:

  • a signed single-chunk payload (hex SHA-256 in x-amz-content-sha256)
  • UNSIGNED-PAYLOAD
  • STREAMING-AWS4-HMAC-SHA256-PAYLOAD (aws-chunked, where the signature of each chunk is verified)

Trailing-checksum modes such as STREAMING-UNSIGNED-PAYLOAD-TRAILER are not on this list. Recent AWS SDK and CLI versions can use those modes by default. If uploads fail with a content-SHA256 mismatch, set AWS_REQUEST_CHECKSUM_CALCULATION=when_required in the environment, or request_checksum_calculation="when_required" in botocore’s Config.

X-Amz-Date must be within 15 minutes of the server clock. The region isn’t enforced: the gateway uses the credential scope’s region from the request, so us-east-1 works.

Credentials come from a JSON file that maps each access key to a secret and a dedup domain:

{
"credentials": [
{"access_key_id": "AKIAEXAMPLEA", "secret_key": "change-me-a", "domain": "tenant-a"},
{"access_key_id": "AKIAEXAMPLEB", "secret_key": "change-me-b", "domain": "tenant-b"}
]
}

Every entry needs all three fields, and access keys must be unique.

Buckets and domains

Buckets are explicit. A client must run CreateBucket before any object operation. Operations on a bucket that was never created return NoSuchBucket.

A bucket is pinned to the dedup domain of the credential that created it. Object keys map directly to refs within that domain, so buckets created by credentials for the same domain share one key namespace. Use one bucket per domain.

Running

Terminal window
cd blobgw-s3
go run ./cmd/blobgw-s3 -listen :8095 -data-dir ./blobgw-s3-data \
-credentials ./credentials.json
FlagDefaultPurpose
-listen:8095HTTP listen address
-data-dir./blobgw-s3-dataLocal casstore directory (manifests and chunks)
-credentials$BLOBGW_S3_CREDENTIALSCredentials JSON file (required)
-compressionzstdPack compression for compressible content: zstd, gzip, or none
-pack-framingper-chunkper-chunk (range-readable) or whole-pack
-pack-size0Pack target in bytes (0 = about 16 MiB)
-max-object-size0PutObject body ceiling (0 = unlimited)
-gc-interval / -gc-safety-window10m / 1hScheduled chunk GC (0 disables) and the minimum age before reclaim
-registry-backendmemorymemory, or jetstream for bucket, credential, and in-flight multipart registries in NATS JetStream KV that survive restarts
-nats-urlNATS defaultNATS server used with -registry-backend=jetstream
-bucket-kv, -credential-kv, -mpu-kvbuilt-in namesJetStream KV bucket names

With the default memory registry, buckets and in-flight multipart uploads are lost on restart. With jetstream, the credentials file is upserted into KV at every start.

The container image is ghcr.io/scitrera/blobgw-s3.

Client examples

AWS CLI

Terminal window
export AWS_ACCESS_KEY_ID=AKIAEXAMPLEA
export AWS_SECRET_ACCESS_KEY=change-me-a
export AWS_DEFAULT_REGION=us-east-1
export AWS_REQUEST_CHECKSUM_CALCULATION=when_required
EP=http://127.0.0.1:8095
aws --endpoint-url $EP s3api create-bucket --bucket models
aws --endpoint-url $EP s3 cp ./checkpoint.safetensors s3://models/run-1/checkpoint.safetensors
aws --endpoint-url $EP s3 ls s3://models/run-1/

Large files uploaded with aws s3 cp use multipart upload automatically.

boto3

import boto3
from botocore.config import Config
s3 = boto3.client(
"s3",
endpoint_url="http://127.0.0.1:8095",
aws_access_key_id="AKIAEXAMPLEA",
aws_secret_access_key="change-me-a",
region_name="us-east-1",
config=Config(
s3={"addressing_style": "path"},
request_checksum_calculation="when_required",
),
)
s3.create_bucket(Bucket="models")
s3.put_object(Bucket="models", Key="notes/a.txt", Body=b"hello", ContentType="text/plain")
print(s3.get_object(Bucket="models", Key="notes/a.txt", Range="bytes=0-1")["Body"].read())
for obj in s3.list_objects_v2(Bucket="models", Prefix="notes/").get("Contents", []):
print(obj["Key"], obj["Size"])

The Content-Type you send decides compression. For example, application/x-safetensors and image/* are stored uncompressed. See How deduplication and compression work.