MCPcopy
hub / github.com/node-formidable/formidable / IncomingForm

Class IncomingForm

src/Formidable.js:84–682  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

82};
83
84class IncomingForm extends EventEmitter {
85 constructor(options = {}) {
86 super();
87
88 this.options = { ...DEFAULT_OPTIONS, ...options };
89 if (!this.options.maxTotalFileSize) {
90 this.options.maxTotalFileSize = this.options.maxFileSize
91 }
92
93 const dir = path.resolve(
94 this.options.uploadDir || this.options.uploaddir || os.tmpdir(),
95 );
96
97 this.uploaddir = dir;
98 this.uploadDir = dir;
99
100 // initialize with null
101 [
102 'error',
103 'headers',
104 'type',
105 'bytesExpected',
106 'bytesReceived',
107 '_parser',
108 'req',
109 ].forEach((key) => {
110 this[key] = null;
111 });
112
113 this._setUpRename();
114
115 this._flushing = 0;
116 this._fieldsSize = 0;
117 this._totalFileSize = 0;
118 this._plugins = [];
119 this.openedFiles = [];
120
121 this.options.enabledPlugins = []
122 .concat(this.options.enabledPlugins)
123 .filter(Boolean);
124
125 if (this.options.enabledPlugins.length === 0) {
126 throw new FormidableError(
127 'expect at least 1 enabled builtin plugin, see options.enabledPlugins',
128 errors.missingPlugin,
129 );
130 }
131
132 this.options.enabledPlugins.forEach((plugin) => {
133 this.use(plugin);
134 });
135
136 this._setUpMaxFields();
137 this._setUpMaxFiles();
138 this.ended = undefined;
139 this.type = undefined;
140 }
141

Callers 1

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…