Adonis Storage Provider
A storage provider for the Adonis framework.
This library provides an easy to use abstraction over multiple storage backends.
Install
npm install --save adonis-storage
Configure
Register it in bootstrap/app.js
:
const providers = ... 'adonis-storage/providers/StorageProvider'
Also consider adding an alias to validation provider.
const aliases = ... Storage: 'Adonis/Addons/Storage'
Add a configuration file in config/storage.js
and copy over the example configurations.
Drivers
Currently, drivers exist for the local file system and Amazon S3.
-
fs
File paths are rooted at
./storage
. You can specify any path inside of the storage directory. -
s3
Files are stored in Amazon S3.
Usage
const Storage = // returns true or false Storage // returns a buffer containing file contents Storage // returns a ReadableStream of the file at path Storage // Store contents at path. If contents is an AdonisJS `file` object,// this is treated as `putFile` Storage // Accepts a path and an AdonisJS `file` object.// When calling `putFile` the name the file is stored as// is automatically calculated as an md5 hash of the // file contents. Storage // Accepts a path and an AdonisJS `file` object.// Same as `putFile` but does not calculate the filename automatically.// File will be stored at `path/to/file/directory/filename` Storage // Return the url or absolute file path for accessing the file Storage
License
Distributed under the MIT license.
Thanks
Special thanks to the creator(s) of AdonisJS for creating such a great framework.