Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/Formidable.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ const createId = cuid2init({ length: 25, fingerprint: CUID2_FINGERPRINT.toLowerC
const DEFAULT_OPTIONS = {
maxFields: 1000,
maxFieldsSize: 20 * 1024 * 1024,
maxFiles: Infinity,
maxFiles: 1000,
maxFileSize: 200 * 1024 * 1024,
maxTotalFileSize: undefined,
minFileSize: 1,
Expand Down
26 changes: 26 additions & 0 deletions test/unit/formidable.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -302,6 +302,32 @@ function makeHeader(originalFilename) {
});
});

test(`${name}: maxFiles exceeded emits error`, (done) => {
const form = getForm(name, { maxFiles: 1 });
form.req = requestStub();

form.on('error', (error) => {
expect(error.message.includes('maxFiles')).toBe(true);
done();
});

const part1 = new Stream();
part1.mimetype = 'text/plain';
const part2 = new Stream();
part2.mimetype = 'text/plain';

form.onPart(part1).then(() => {
part1.emit('data', Buffer.alloc(1));
part1.emit('end');
form.onPart(part2);
});
});

test(`${name}: maxFiles defaults to 1000`, () => {
const form = getForm(name);
expect(form.options.maxFiles).toBe(1000);
});

// test(`${name}: use custom options.originalFilename instead of form._uploadPath`, () => {
// const form = getForm(name, {
// originalFilename: (_) => path.join(__dirname, 'sasa'),
Expand Down
Loading