1.3.0 • Published 2 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
3 months ago
1.0.17
3 months ago
1.0.16
3 months ago
1.2.5
2 months ago
1.3.0
2 months ago
1.0.15
3 months ago
1.0.14
3 months ago
1.0.13
4 months ago
1.0.12
4 months ago
1.0.9
5 months ago
1.0.8
6 months ago
1.0.7
6 months ago
1.0.6
8 months ago
1.0.11
5 months ago
1.0.10
5 months ago
1.0.5
9 months ago
1.0.4
9 months ago
1.0.3
9 months ago
1.0.2
9 months ago
1.0.1
11 months ago
1.0.0
1 year ago