1.3.0 • Published 3 months ago
@storecraft/storage-s3-compatible v1.3.0
Storecraft S3 compatible storage
fetch
ready support for an S3
like storage:
Amazon S3
Cloudflare R2
DigitalOcean Spaces
minIO
servers
Features:
- Works in any
js
runtime and platform that supportsfetch
- Supports streaming
Get
/Put
/Delete
- Supports
presigned
Get
/Put
requests to offload to client
npm i @storecraft/storage-s3-compatible
AWS 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 (tomer.shalev@gmail.com)
1.0.18
4 months ago
1.0.17
4 months ago
1.0.16
4 months ago
1.2.5
3 months ago
1.3.0
3 months ago
1.0.15
4 months ago
1.0.14
4 months ago
1.0.13
5 months ago
1.0.12
5 months ago
1.0.9
6 months ago
1.0.8
7 months ago
1.0.7
7 months ago
1.0.6
9 months ago
1.0.11
6 months ago
1.0.10
6 months ago
1.0.5
10 months ago
1.0.4
10 months ago
1.0.3
10 months ago
1.0.2
10 months ago
1.0.1
12 months ago
1.0.0
1 year ago