Closed SourceBoy closed 1 year ago
Due to the nature of multipart/form-data, there is no way to know how many files or fields beforehand. You could require a field at the very beginning of the form to hold such a count, but if the form is coming from an arbitrary user you cannot necessarily trust its value.
Any way to get the files count before listening to
on('file')
?I've got a use case where I'm calling
.end(request.rawBody)
instead of piping due to using serverless functions.on('file')
is wrapped inside of anew Promise
and can only be resolved once all the files are processed.I'm using a counter inside of
on('file')
but doesn't have a value to compare the counter to in order to resolve the promise.(Using
on/once close/end/finish
results in prematurely resolving the promise as the processing isn't complete yet.)