Reference — /s3
import { S3ObjectStore } from 'git-fs-s3/s3';Runtime support
Section titled “Runtime support”Node.jsCloudflare WorkersDenoBrowser
Constructor
Section titled “Constructor”class
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
Section titled “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
Section titled “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,});@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.