Skip to content

Reference — /s3

import { S3ObjectStore } from 'git-fs-s3/s3';

Node.jsCloudflare WorkersDenoBrowser

new S3ObjectStore(options: S3ObjectStoreOptions)
ParameterTypeDescription
options.clientS3ClientA configured client — works with AWS S3, Cloudflare R2, MinIO, Backblaze B2.
options.bucketstring
options.prefix?stringKey prefix for every object.
options.contentType?(key: string) => string | undefinedDerives a Content-Type for uploads. Cosmetic only — git never reads it back.

Implements ObjectStore (see the guide) over any S3-compatible API, including the optional getRange.

S3ObjectStore implements the optional ObjectStore.getRange with S3’s Range header, inclusive at both ends, returning null when the key doesn’t exist. This is what lets getObjectSize answer an object’s size without fetching the pack that holds it; a store without getRange makes that function report null, and the caller reads the object instead.

import { S3Client } from '@aws-sdk/client-s3';
import { S3ObjectStore } from 'git-fs-s3/s3';
const store = new S3ObjectStore({
client: new S3Client({
region: 'auto',
endpoint: process.env.R2_ENDPOINT, // omit for AWS S3
credentials: {
accessKeyId: process.env.R2_ACCESS_KEY_ID!,
secretAccessKey: process.env.R2_SECRET_ACCESS_KEY!,
},
}),
bucket: 'my-git-repos',
contentType: (key) =>
/\/(HEAD|config)$|\/refs\//.test(key) ? 'text/plain' : undefined,
});

@aws-sdk/client-s3 is an optional peer dependency, loaded only when you import this subpath — the root package and /http//ops never pull it in.