I have an input field like:
input(type='file', id='avatar', name='avatar', class='fivecol', accept='image/*')
and in my controller I check for req.files.avatar... Even when it's empty, the output still is logged and it temporarily stores (something) in /uploads.
Here is a console log of req.files.avatar
{ avatar:
{ domain: null,
_events: null,
_maxListeners: 10,
size: 0,
path: 'uploads/aa7571f48cc1d0a3d1242d737f8c5fa0',
name: '',
type: 'application/octet-stream',
hash: false,
lastModifiedDate: null,
_writeStream:
{ domain: null,
_events: null,
_maxListeners: 10,
path: 'uploads/aa7571f48cc1d0a3d1242d737f8c5fa0',
fd: 21,
writable: false,
flags: 'w',
encoding: 'binary',
mode: 438,
bytesWritten: 0,
busy: false,
_queue: [],
_open: [Function] },
length: [Getter],
filename: [Getter],
mime: [Getter] } }
Why is it doing this? Also, there is a file that is 0 bytes in that /uploads folder named aa7571f48cc1d0a3d1242d737f8c5fa0 (or whatever other random hash gets generated each time).
Additionally, why isn't express clearing those temporarily uploaded files out of /uploads?