UNPKG

1.21 kBMarkdownView Raw
1# multer-s3
2Streaming multer storage engine for AWS S3
3
4This project is mostly an integration piece for existing code samples from Multer's [storage engine documentation](https://github.com/expressjs/multer/blob/master/StorageEngine.md) with [s3fs](https://github.com/RiptideElements/s3fs) as the substitution piece for file system. Existing solutions I found required buffering the multipart uploads into the actual filesystem which is difficult to scale.
5
6# Install
7```
8npm install --save multer-s3
9```
10
11# Tests
12Tested with [s3rver](https://github.com/jamhall/s3rver) instead of your actual s3 credentials. Doesn't require a real account or changing of hosts files. Includes integration tests ensuring that it should work with express + multer.
13
14```
15npm test
16```
17
18# Usage
19```
20var express = require('express');
21var app = express();
22var multer = require('multer');
23var s3 = require('multer-s3');
24
25var upload = multer({
26 storage: s3({
27 dirname: 'uploads/photos',
28 bucket: 'some-bucket',
29 secretAccessKey: 'some secret',
30 accessKeyId: 'some key',
31 region: 'us-east-1'
32 })
33})
34
35app.post('/upload', upload.array('photos', 3), function(req, res, next){
36 res.send('Successfully uploaded!');
37});
38```