mirror of
https://github.com/BobbyWibowo/lolisafe.git
synced 2025-02-07 13:59:01 +00:00
Cleaned multerStorageController.js
This commit is contained in:
parent
8e5e6ce018
commit
67a69bf4e2
@ -1,29 +1,16 @@
|
|||||||
const fs = require('fs')
|
const fs = require('fs')
|
||||||
const os = require('os')
|
|
||||||
const path = require('path')
|
const path = require('path')
|
||||||
const crypto = require('crypto')
|
|
||||||
const blake3 = require('blake3')
|
const blake3 = require('blake3')
|
||||||
const mkdirp = require('mkdirp')
|
const mkdirp = require('mkdirp')
|
||||||
|
|
||||||
function getFilename (req, file, cb) {
|
|
||||||
// This won't be used since we use our own filename function.
|
|
||||||
crypto.randomBytes(16, function (err, raw) {
|
|
||||||
cb(err, err ? undefined : raw.toString('hex'))
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
function getDestination (req, file, cb) {
|
|
||||||
cb(null, os.tmpdir())
|
|
||||||
}
|
|
||||||
|
|
||||||
function DiskStorage (opts) {
|
function DiskStorage (opts) {
|
||||||
this.getFilename = (opts.filename || getFilename)
|
this.getFilename = opts.filename
|
||||||
|
|
||||||
if (typeof opts.destination === 'string') {
|
if (typeof opts.destination === 'string') {
|
||||||
mkdirp.sync(opts.destination)
|
mkdirp.sync(opts.destination)
|
||||||
this.getDestination = function ($0, $1, cb) { cb(null, opts.destination) }
|
this.getDestination = function ($0, $1, cb) { cb(null, opts.destination) }
|
||||||
} else {
|
} else {
|
||||||
this.getDestination = (opts.destination || getDestination)
|
this.getDestination = opts.destination
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user