mirror of
https://github.com/TryGhost/Ghost.git
synced 2025-01-01 23:37:43 +03:00
Refactored upload middleware
refs https://linear.app/tryghost/issue/CORE-121/create-a-video-storage-adapter - Using a wrapping object to store enableClear/multer instances didn't make any sense
This commit is contained in:
parent
4a551661d9
commit
f9a8edb1a0
@ -34,20 +34,19 @@ const messages = {
|
||||
}
|
||||
};
|
||||
|
||||
const upload = {
|
||||
enabledClear: config.get('uploadClear') || true,
|
||||
multer: multer({dest: os.tmpdir()})
|
||||
};
|
||||
const enabledClear = config.get('uploadClear') || true;
|
||||
const upload = multer({dest: os.tmpdir()});
|
||||
|
||||
const deleteSingleFile = file => fs.unlink(file.path).catch(err => logging.error(err));
|
||||
|
||||
const single = name => (req, res, next) => {
|
||||
const singleUpload = upload.multer.single(name);
|
||||
const singleUpload = upload.single(name);
|
||||
|
||||
singleUpload(req, res, (err) => {
|
||||
if (err) {
|
||||
return next(err);
|
||||
}
|
||||
if (upload.enabledClear) {
|
||||
if (enabledClear) {
|
||||
const deleteFiles = () => {
|
||||
res.removeListener('finish', deleteFiles);
|
||||
res.removeListener('close', deleteFiles);
|
||||
|
Loading…
Reference in New Issue
Block a user