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

Method _newFile

src/Formidable.js:520–549  ·  view source on GitHub ↗
({ filepath, originalFilename, mimetype, newFilename })

Source from the content-addressed store, hash-verified

518 }
519
520 async _newFile({ filepath, originalFilename, mimetype, newFilename }) {
521 if (this.options.fileWriteStreamHandler) {
522 return new VolatileFile({
523 newFilename,
524 filepath,
525 originalFilename,
526 mimetype,
527 createFileWriteStream: this.options.fileWriteStreamHandler,
528 hashAlgorithm: this.options.hashAlgorithm,
529 });
530 }
531 if (this.options.createDirsFromUploads) {
532 try {
533 await createNecessaryDirectoriesAsync(filepath);
534 } catch (errorCreatingDir) {
535 this._error(new FormidableError(
536 `cannot create directory`,
537 errors.cannotCreateDir,
538 409,
539 ));
540 }
541 }
542 return new PersistentFile({
543 newFilename,
544 filepath,
545 originalFilename,
546 mimetype,
547 hashAlgorithm: this.options.hashAlgorithm,
548 });
549 }
550
551 _getFileName(headerValue) {
552 // matches either a quoted-string or a token (RFC 2616 section 19.5.1)

Callers 2

_handlePartMethod · 0.95
initFunction · 0.80

Calls 1

_errorMethod · 0.95

Tested by

no test coverage detected