1 | var concat = require('concat-stream')
|
2 |
|
3 | function MemoryStorage (opts) {}
|
4 |
|
5 | MemoryStorage.prototype._handleFile = function _handleFile (req, file, cb) {
|
6 | file.stream.pipe(concat({ encoding: 'buffer' }, function (data) {
|
7 | cb(null, {
|
8 | buffer: data,
|
9 | size: data.length
|
10 | })
|
11 | }))
|
12 | }
|
13 |
|
14 | MemoryStorage.prototype._removeFile = function _removeFile (req, file, cb) {
|
15 | delete file.buffer
|
16 | cb(null)
|
17 | }
|
18 |
|
19 | module.exports = function (opts) {
|
20 | return new MemoryStorage(opts)
|
21 | }
|