@remix-run/file-storage-s3
v0.1.0
Published
S3 backend for @remix-run/file-storage
Readme
file-storage-s3
S3 backend for remix/file-storage.
Use this package when you want the FileStorage API backed by AWS S3 or an S3-compatible provider.
Features
- S3-Compatible API - Works with AWS S3 and S3-compatible APIs (e.g. MinIO, LocalStack)
- Metadata Preservation - Preserves
Filemetadata (name,type,lastModified) - Runtime-Agnostic Signing - Uses
aws4fetchfor SigV4 signing
Installation
npm i remixUsage
import { createS3FileStorage } from 'remix/file-storage-s3'
let storage = createS3FileStorage({
accessKeyId: process.env.AWS_ACCESS_KEY_ID!,
secretAccessKey: process.env.AWS_SECRET_ACCESS_KEY!,
bucket: 'my-app-uploads',
region: 'us-east-1',
})
await storage.set(
'uploads/hello.txt',
new File(['hello world'], 'hello.txt', { type: 'text/plain' }),
)
let file = await storage.get('uploads/hello.txt')
await storage.remove('uploads/hello.txt')For S3-compatible providers such as MinIO and LocalStack, set endpoint and forcePathStyle: true.
Related Packages
file-storage- CoreFileStorageinterface and filesystem/memory backendsform-data-parser- Parsesmultipart/form-datauploads intoFileUploadobjects
License
See LICENSE
