i'm using multer v1.3.0 express v4.15.4.
i have used filesize limits below
multer({ storage: storage, limits: {filesize: 1*1000*50, files:1}, filefilter: function (req, file, cb) { if (_.indexof(['image/jpeg', 'image/png'], file.mimetype) == -1) cb(null, false); else cb(null, true) } });
in case dont think limits working. cause not getting limit_file_size error.
if remove filefilter i'm getting limit_file_size error.
but in both cases first whole file getting uploaded & filesize checked.
its not @ upload 1gb of file , check of 1mb or not. want know if there has way stop uploading in middle when file size limit exceeds. don't want rely on content-length.
from looking through multer
, busboy
source looks calculates data size running total , stops reading stream filesize
reached. see code here:
so while 1gb might uploaded shouldn't saved anywhere.
if want stop upload continuing think you'd have close socket though haven't experimented myself. i'm not aware of way respond cleanly while request still trying upload data.
related:
yes or no: can server send http response, while still uploading file correlative http request?
Comments
Post a Comment