@storecraft/storage-s3-compatible
v1.3.0
Published
Official S3-Compatible Storage adapter for storecraft
Maintainers
Readme
Storecraft S3 compatible storage
fetch ready support for an S3 like storage:
Amazon S3Cloudflare R2DigitalOcean SpacesminIOservers
Features:
- Works in any
jsruntime and platform that supportsfetch - Supports streaming
Get/Put/Delete - Supports
presignedGet/Putrequests to offload to client
npm i @storecraft/storage-s3-compatibleAWS S3
import { App } from '@storecraft/core';
import { S3 } from '@storecraft/storage-s3-compatible'
const app = new App()
.withPlatform(new NodePlatform())
.withDatabase(new MongoDB())
.withStorage(
new S3(
{
forcePathStyle: FORCE_PATH_STYLE,
bucket: process.env.S3_BUCKET,
region: process.env.S3_REGION,
accessKeyId: process.env.S3_ACCESS_KEY_ID,
secretAccessKey: process.env.S3_SECRET_KEY
}
)
).init();config
Storecraft will search the following env variables
S3_BUCKET=...
S3_REGION=...
S3_ACCESS_KEY_ID=...
S3_SECRET_KEY=...So, you can instantiate with empty config
.withStorage(
new S3()
)Cloudflare R2
import { App } from '@storecraft/core';
import { R2 } from '@storecraft/storage-s3-compatible'
const app = new App()
.withPlatform(new NodePlatform())
.withDatabase(new MongoDB())
.withStorage(
new R2(
{
account_id: process.env.CF_ACCOUNT_ID,
bucket: process.env.S3_BUCKET,
accessKeyId: process.env.S3_ACCESS_KEY_ID,
secretAccessKey: process.env.S3_SECRET_ACCESS_KEY
}
)
).init();
config
Storecraft will search the following env variables
CF_ACCOUNT_ID=...
S3_BUCKET=...
S3_ACCESS_KEY_ID=...
S3_SECRET_ACCESS_KEY=...So, you can instantiate with empty config
.withStorage(
new R2()
)Any S3 compatible storage (minio for example)
import { App } from '@storecraft/core';
import { S3CompatibleStorage } from '@storecraft/storage-s3-compatible'
const app = new App()
.withPlatform(new NodePlatform())
.withDatabase(new MongoDB())
.withStorage(
new S3CompatibleStorage(
{
endpoint: process.env.S3_ENDPOINT,
accessKeyId: process.env.S3_ACCESS_KEY_ID,
secretAccessKey: process.env.S3_SECRET_ACCESS_KEY,
bucket: process.env.S3_BUCKET,
region: process.env.S3_REGION
forcePathStyle: true,
}
)
).init();config
Storecraft will search the following env variables
S3_ENDPOINT=...
S3_BUCKET=...
S3_REGION=...
S3_ACCESS_KEY_ID=...
S3_SECRET_KEY=...So, you can instantiate with empty config
.withStorage(
new S3CompatibleStorage()
)Author: Tomer Shalev ([email protected])