Reference — /s3
S3ObjectStore, the ObjectStore implementation over @aws-sdk/client-s3.
import { S3ObjectStore } from 'git-fs-s3/s3';Runtime support
Node.jsCloudflare WorkersDenoBrowser
Constructor
S3ObjectStorenew S3ObjectStore(options: S3ObjectStoreOptions)| Parameter | Type | Description |
|---|---|---|
options.client | S3Client | A configured client — works with AWS S3, Cloudflare R2, MinIO, Backblaze B2. |
options.bucket | string | |
options.prefix? | string | Key prefix for every object. |
options.contentType? | (key: string) => string | undefined | Derives 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.
Range reads
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.
Example
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,
});Notes
One instance per bucket/prefix — but reuse a single S3Client across
every store you create. A busy repo page can mean hundreds of object
reads; a shared client pools HTTP connections instead of reconnecting
per store.
@aws-sdk/client-s3 is an optional peer dependency, loaded only when you