Skip to content

talu/multer-s3

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

24 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

multer-s3

Streaming multer storage engine for AWS S3

This project is mostly an integration piece for existing code samples from Multer's storage engine documentation with 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.

Install

npm install --save multer-s3

Tests

Tested with 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.

npm test

Usage

var express = require('express');
var app = express();
var multer = require('multer');
var s3 = require('multer-s3');

var upload = multer({
  storage: s3({
    dirname: 'uploads/photos',
    bucket: 'some-bucket',
    secretAccessKey: 'some secret',
    accessKeyId: 'some key',
    region: 'us-east-1',
    filename: function (req, file, cb) {
      cb(null, Date.now())
    }
  })
})

app.post('/upload', upload.array('photos', 3), function(req, res, next){
  res.send('Successfully uploaded!');
});

About

multer storage engine for amazon s3

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • JavaScript 100.0%