Store and retreive files on S3.
npm install --save @filestore/s3
const S3 = require('@filestore/s3')
const fs = require('fs')
const filestore = new S3({ bucket: 'my-files' })
const file = fs.createReadStream('my-file.txt')
filestore.put('my-file.txt', file).then(() => {
// "my-file.txt" is now uploaded to the S3 bucket "my-files"
})
The API is meant to be interchangeable with any other @filestore/...
module.
options.bucket
- Name of the bucket to store files inoptions.prefix
- Prefix that will be prepended to each key in S3 (e.g."files/"
)
Instantiates a new S3 FileStore class.
Upload a file to S3.
data
can be a ReadableStream
, Buffer
, string
, Iterable<Buffer|string>
or Promise
.
Fetch a file from S3.
Check if a file exists on S3.