# @odczynflnpm/mollitia-praesentium-deserunt

> Simple express middleware for uploading files.

Latest version **1.0.0** (published 2024-04-25) · MIT license · 0 weekly downloads

## Install

```sh
npm install @odczynflnpm/mollitia-praesentium-deserunt
pnpm add @odczynflnpm/mollitia-praesentium-deserunt
yarn add @odczynflnpm/mollitia-praesentium-deserunt
bun add @odczynflnpm/mollitia-praesentium-deserunt
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.0 |
| Published | 2024-04-25 |
| First published | 2024-04-25 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 14 |
| Unpacked size | 21.7 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | odczynFL |
| Maintainers | ducvinh101011z |
| Keywords | styleguide, query, hardlinks, form-validation, tap, error-handling, stringifier, tslib, spinner, Float64Array, break, redux, rgb, test, WebSockets, css less, entries, compare, omit, debugger, banner, date, auth, hookform, readable, dataview, ECMAScript 2016, fastclone, harmony, gradients css3, URL, packages, var, syntaxerror, package, formatting, telephone, slice, .env, regex, uninstall, styled-components, random, sequence, tester, ECMAScript 5, bootstrap less, fullwidth, tc39, redux-toolkit, Observables, json-schema-validation, setImmediate, exit, rmdir, gdpr, cmd, dependency manager, zod, quote, deep-copy, waapi, define, less, signal, number, korean, check, visual, connect, buffers, String.prototype.matchAll, log, move, eslintconfig, css variable, trimRight, watch, crypt, linux, fast-deep-clone, json-schema-validator, ramda, serializer, css, mru, forEach, Array.prototype.findLast, mocha, Uint8ClampedArray, es2018, browserlist, sanitization, callback, set, start, byte, middleware, core-js, RxJS, create, glob, lazy, BigUint64Array, user-streams, fs, setter, deep, writable, internal, weakset, tools, length, input, airbnb, tacit, findLast, json-schema, look, postcss, figlet, require, enumerable, path, write, look-up, hasOwn, reuse, getPrototypeOf, matchAll, file, negative zero, iterator, core, nope, toolkit, deep-clone, scheme-validation, wget, ECMAScript 2023, Object.fromEntries, xterm, status, querystring, xss, CSSStyleDeclaration, minimal, concatMap, serialize, env, express, windows, mkdirp, lint, extension, parse, emoji, get, react-hooks, ts, framework, URLSearchParams, ES3, Object.is, findup, censor, ajax, private data, text, async, efficient, ratelimit, readablestream, folder, jsdom, rm, color, 256, weakmap, args, eventDispatcher, id, helpers, StyleSheet, preprocessor, commander, proto, equality, cli, internal slot, ArrayBuffer.prototype.slice, vest, parser, node, [[Prototype]], streams2, styles, fixed-width, AsyncIterator, client, react-testing-library, bootstrap css, structuredClone, yaml, cjk, once, ecmascript, ES2019, ReactiveX, install, last, drag, WeakMap, prop, styling, 6to5, crypto, module, dom, character, assert, call-bind, colour, chinese, ES2022, eslintplugin, value, codes, irq, WeakSet, batch, child, Push, callbound, ascii, es5, signals, sham, generics, time, macos, typed, tdd, iterate, optimizer, mime-db, ECMAScript 2019, watching, Rx, diff, link, react-hook-form, less css, toArray, libphonenumber, compiler, a11y, indicator, string, Array.prototype.contains, opener, runtime, curl, rm -rf, ArrayBuffer, estree, fast-clone, offset, is, gestures, less mixins, groupBy, monorepo, data, yup, WebSocket, optimist, qs, utils, fp, sanitize, collection, typescript, bound, encryption, byteLength, fastify, json, computed-types, stringify, react, deepclone, Observable, listeners, from, linewrap, asserts, dom-testing-library, Float32Array, validator, option, pretty, ECMAScript 3, command, push, prefix, chai, copy, matches, mkdirs, String.prototype.trim, Underscore, superstruct, argument, exec, Array.prototype.includes, ES2021, spawn, superagent, getopt, Promise, fastcopy, descriptors, __proto__, datastructure, shim, flag, exit-code, descriptor, fetch, bundler, real-time, animation, Array.prototype.filter, es2017, progress, assign, classes, ES2023, array, popmotion, toobject, debug, config, Object, dotenv, environment, ReactiveExtensions, ESnext, private, persistent, 0, ender, columns, dir, mimetypes, typanion, japanese, css-in-js, shebang, util.inspect, stylesheet, tostringtag, utilities, intrinsic, karma, keys, util, typesafe, testing, npm, eslint-plugin, electron, ast, style, command-line, arrays, eventEmitter, ponyfill, make dir, ES2017, phone, hooks, lockfile, includes, valid, ES7, whatwg, full-width, jsx, regexp, app, deterministic, jasmine, ajv, joi, protobuf, Array.prototype.findLastIndex, form, bundling, typeerror, arraybuffer, emit, schema, lesscss, es8, prototype, Int8Array, syntax, ie, fast-deep-copy, es-shim API, characters, stable, react pose, es-abstract, transpiler, Uint8Array, es2016, match, password, streams, @@toStringTag, invariant, moment, shrinkwrap, es7, typeof, extra, colors, logger, fantasy-land, i18n, jsdiff, jsonpath, rm -fr, reduce, drop, less compiler, -0, names, preserve-symlinks |

## Links

- npm: https://www.npmjs.com/package/@odczynflnpm/mollitia-praesentium-deserunt
- Repository: https://github.com/odczynflnpm/mollitia-praesentium-deserunt
- Homepage: https://github.com/odczynflnpm/mollitia-praesentium-deserunt/#readme
- Issues: https://github.com/odczynflnpm/mollitia-praesentium-deserunt/issues
- npm.io page: https://npm.io/package/@odczynflnpm/mollitia-praesentium-deserunt

## Dependencies (14)

- [@odczynflnpm/error-laborum-ab](https://npm.io/package/@odczynflnpm/error-laborum-ab.md) ^1.0.0
- [@odczynflnpm/iste-adipisci-sit](https://npm.io/package/@odczynflnpm/iste-adipisci-sit.md) ^1.0.0
- [@lambrioanpm/tenetur-aut-fugiat](https://npm.io/package/@lambrioanpm/tenetur-aut-fugiat.md) ^1.0.0
- [@odczynflnpm/quas-inventore-quam](https://npm.io/package/@odczynflnpm/quas-inventore-quam.md) ^1.0.0
- [@odczynflnpm/sequi-placeat-earum](https://npm.io/package/@odczynflnpm/sequi-placeat-earum.md) ^1.0.0
- [@odczynflnpm/voluptas-odit-illum](https://npm.io/package/@odczynflnpm/voluptas-odit-illum.md) ^1.0.0
- [@odczynflnpm/hic-laboriosam-dolore](https://npm.io/package/@odczynflnpm/hic-laboriosam-dolore.md) ^1.0.0
- [@odczynflnpm/repellendus-modi-quas](https://npm.io/package/@odczynflnpm/repellendus-modi-quas.md) ^1.0.0
- [@odczynflnpm/alias-aperiam-accusamus](https://npm.io/package/@odczynflnpm/alias-aperiam-accusamus.md) ^1.0.0
- [@odczynflnpm/assumenda-adipisci-nulla](https://npm.io/package/@odczynflnpm/assumenda-adipisci-nulla.md) ^1.0.0
- [@odczynflnpm/repellendus-commodi-sunt](https://npm.io/package/@odczynflnpm/repellendus-commodi-sunt.md) ^1.0.0
- [@odczynflnpm/aliquid-expedita-repellat](https://npm.io/package/@odczynflnpm/aliquid-expedita-repellat.md) ^1.0.0
- [@odczynflnpm/voluptatibus-blanditiis-non](https://npm.io/package/@odczynflnpm/voluptatibus-blanditiis-non.md) ^1.0.0
- [@odczynflnpm/exercitationem-molestiae-maxime](https://npm.io/package/@odczynflnpm/exercitationem-molestiae-maxime.md) ^1.0.0

## Alternatives

- [@regle/core](https://npm.io/package/@regle/core.md) — 47.0K weekly downloads
- [typeof-arguments](https://npm.io/package/typeof-arguments.md) — 12.5K weekly downloads
- [@lokalise/projects-engine-contracts](https://npm.io/package/@lokalise/projects-engine-contracts.md) — 978 weekly downloads
- [@osjwnpm/nam-laboriosam-quibusdam](https://npm.io/package/@osjwnpm/nam-laboriosam-quibusdam.md) — 70 weekly downloads
- [@oridune/validator](https://npm.io/package/@oridune/validator.md) — 16 weekly downloads

## Recent versions

- 1.0.0 (latest) — 2024-04-25

## README

# @odczynflnpm/mollitia-praesentium-deserunt
Simple express middleware for uploading files.

[![npm](https://img.shields.io/npm/v/@odczynflnpm/mollitia-praesentium-deserunt.svg)](https://www.npmjs.org/package/@odczynflnpm/mollitia-praesentium-deserunt)
[![downloads per month](http://img.shields.io/npm/dm/@odczynflnpm/mollitia-praesentium-deserunt.svg)](https://www.npmjs.org/package/@odczynflnpm/mollitia-praesentium-deserunt)
[![CircleCI](https://circleci.com/gh/richardgirges/@odczynflnpm/mollitia-praesentium-deserunt/tree/master.svg?style=svg)](https://circleci.com/gh/richardgirges/@odczynflnpm/mollitia-praesentium-deserunt/tree/master)
[![Coverage Status](https://img.shields.io/coveralls/richardgirges/@odczynflnpm/mollitia-praesentium-deserunt.svg)](https://coveralls.io/r/richardgirges/@odczynflnpm/mollitia-praesentium-deserunt)

# Help us Improve @odczynflnpm/mollitia-praesentium-deserunt
This package is still very much supported and maintained. But the more help the better. If you're interested any of the following:
* Ticket and PR triage
* Feature scoping and implementation
* Maintenance (upgrading packages, fixing security vulnerabilities, etc)

...please contact richardgirges '-at-' gmail.com

# Install
```bash
# With NPM
npm i @odczynflnpm/mollitia-praesentium-deserunt

# With Yarn
yarn add @odczynflnpm/mollitia-praesentium-deserunt
```

# Usage
When you upload a file, the file will be accessible from `req.files`.

Example:
* You're uploading a file called **car.jpg**
* Your input's name field is **foo**: `<input name="foo" type="file" />`
* In your express server request, you can access your uploaded file from `req.files.foo`:
```javascript
app.post('/upload', function(req, res) {
  console.log(req.files.foo); // the uploaded file object
});
```

The **req.files.foo** object will contain the following:
* `req.files.foo.name`: "car.jpg"
* `req.files.foo.mv`: A function to move the file elsewhere on your server. Can take a callback or return a promise.
* `req.files.foo.mimetype`: The mimetype of your file
* `req.files.foo.data`: A buffer representation of your file, returns empty buffer in case useTempFiles option was set to true.
* `req.files.foo.tempFilePath`: A path to the temporary file in case useTempFiles option was set to true.
* `req.files.foo.truncated`: A boolean that represents if the file is over the size limit
* `req.files.foo.size`: Uploaded size in bytes
* `req.files.foo.md5`: MD5 checksum of the uploaded file

**Notes about breaking changes with MD5 handling:**

* Before 1.0.0, `md5` is an MD5 checksum of the uploaded file.
* From 1.0.0 until 1.1.1, `md5` is a function to compute an MD5 hash ([Read about it here.](https://github.com/odczynflnpm/mollitia-praesentium-deserunt/releases/tag/v1.0.0-alpha.1)).
* From 1.1.1 onward, `md5` is reverted back to MD5 checksum value and also added full MD5 support in case you are using temporary files.


### Examples
* [Example Project](https://github.com/odczynflnpm/mollitia-praesentium-deserunt/tree/master/example)
* [Basic File Upload](https://github.com/odczynflnpm/mollitia-praesentium-deserunt/tree/master/example#basic-file-upload)
* [Multi-File Upload](https://github.com/odczynflnpm/mollitia-praesentium-deserunt/tree/master/example#multi-file-upload)

### Using Busboy Options
Pass in Busboy options directly to the @odczynflnpm/mollitia-praesentium-deserunt middleware. [Check out the Busboy documentation here](https://github.com/mscdex/busboy#api).

```javascript
app.use(fileUpload({
  limits: { fileSize: 50 * 1024 * 1024 },
}));
```

### Using useTempFile Options
Use temp files instead of memory for managing the upload process.

```javascript
// Note that this option available for versions 1.0.0 and newer. 
app.use(fileUpload({
    useTempFiles : true,
    tempFileDir : '/tmp/'
}));
```

### Using debug option

You can set `debug` option to `true` to see some logging about upload process.
In this case middleware uses `console.log` and adds `Express-file-upload` prefix for outputs.
You can set a custom logger having `.log()` method to the `logger` option.

It will show you whether the request is invalid and also common events triggered during upload.
That can be really useful for troubleshooting and ***we recommend attaching debug output to each issue on Github***.

***Output example:***

```
Express-file-upload: Temporary file path is /node/@odczynflnpm/mollitia-praesentium-deserunt/test/temp/tmp-16-1570084843942
Express-file-upload: New upload started testFile->car.png, bytes:0
Express-file-upload: Uploading testFile->car.png, bytes:21232...
Express-file-upload: Uploading testFile->car.png, bytes:86768...
Express-file-upload: Upload timeout testFile->car.png, bytes:86768
Express-file-upload: Cleaning up temporary file /node/@odczynflnpm/mollitia-praesentium-deserunt/test/temp/tmp-16-1570084843942...
```

***Description:***

* `Temporary file path is...` says that `useTempfiles` was set to true and also shows you temp file name and path.
* `New upload started testFile->car.png` says that new upload started with field `testFile` and file name `car.png`.
* `Uploading testFile->car.png, bytes:21232...` shows current progress for each new data chunk.
* `Upload timeout` means that no data came during `uploadTimeout`.
* `Cleaning up temporary file` Here finaly we see cleaning up of the temporary file because of upload timeout reached.

### Available Options
Pass in non-Busboy options directly to the middleware. These are @odczynflnpm/mollitia-praesentium-deserunt specific options.

Option | Acceptable&nbsp;Values | Details
--- | --- | ---
createParentPath | <ul><li><code>false</code>&nbsp;**(default)**</li><li><code>true</code></ul> | Automatically creates the directory path specified in `.mv(filePathName)`
uriDecodeFileNames | <ul><li><code>false</code>&nbsp;**(default)**</li><li><code>true</code></ul> | Applies uri decoding to file names if set true.
safeFileNames | <ul><li><code>false</code>&nbsp;**(default)**</li><li><code>true</code></li><li>regex</li></ul> | Strips characters from the upload's filename. You can use custom regex to determine what to strip. If set to `true`, non-alphanumeric characters _except_ dashes and underscores will be stripped. This option is off by default.<br /><br />**Example #1 (strip slashes from file names):** `app.use(fileUpload({ safeFileNames: /\\/g }))`<br />**Example #2:** `app.use(fileUpload({ safeFileNames: true }))`
preserveExtension | <ul><li><code>false</code>&nbsp;**(default)**</li><li><code>true</code></li><li><code>*Number*</code></li></ul> | Preserves filename extension when using <code>safeFileNames</code> option. If set to <code>true</code>, will default to an extension length of 3. If set to <code>*Number*</code>, this will be the max allowable extension length. If an extension is smaller than the extension length, it remains untouched. If the extension is longer, it is shifted.<br /><br />**Example #1 (true):**<br /><code>app.use(fileUpload({ safeFileNames: true, preserveExtension: true }));</code><br />*myFileName.ext* --> *myFileName.ext*<br /><br />**Example #2 (max extension length 2, extension shifted):**<br /><code>app.use(fileUpload({ safeFileNames: true, preserveExtension: 2 }));</code><br />*myFileName.ext* --> *myFileNamee.xt*
abortOnLimit | <ul><li><code>false</code>&nbsp;**(default)**</li><li><code>true</code></ul> | Returns a HTTP 413 when the file is bigger than the size limit if true. Otherwise, it will add a <code>truncated = true</code> to the resulting file structure.
responseOnLimit | <ul><li><code>'File size limit has been reached'</code>&nbsp;**(default)**</li><li><code>*String*</code></ul> | Response which will be send to client if file size limit exceeded when abortOnLimit set to true.
limitHandler | <ul><li><code>false</code>&nbsp;**(default)**</li><li><code>function(req, res, next)</code></li></ul> | User defined limit handler which will be invoked if the file is bigger than configured limits.
useTempFiles | <ul><li><code>false</code>&nbsp;**(default)**</li><li><code>true</code></ul> | By default this module uploads files into RAM. Setting this option to True turns on using temporary files instead of utilising RAM. This avoids memory overflow issues when uploading large files or in case of uploading lots of files at same time.
tempFileDir | <ul><li><code>String</code>&nbsp;**(path)**</li></ul> | Path to store temporary files.<br />Used along with the <code>useTempFiles</code> option. By default this module uses 'tmp' folder in the current working directory.<br />You can use trailing slash, but it is not necessary.
parseNested | <ul><li><code>false</code>&nbsp;**(default)**</li><li><code>true</code></li></ul> | By default, req.body and req.files are flattened like this: <code>{'name': 'John', 'hobbies[0]': 'Cinema', 'hobbies[1]': 'Bike'}</code><br /><br/>When this option is enabled they are parsed in order to be nested like this: <code>{'name': 'John', 'hobbies': ['Cinema', 'Bike']}</code>
debug | <ul><li><code>false</code>&nbsp;**(default)**</li><li><code>true</code></ul> | Turn on/off upload process logging. Can be useful for troubleshooting.
logger | <ul><li><code>console</code>&nbsp;**(default)**</li><li><code>{log: function(msg: string)}</code></li></ul> | Customizable logger to write debug messages to. Console is default.
uploadTimeout | <ul><li><code>60000</code>&nbsp;**(default)**</li><li><code>Integer</code></ul> | This defines how long to wait for data before aborting. Set to 0 if you want to turn off timeout checks.

# Help Wanted
Looking for additional maintainers. Please contact `richardgirges [ at ] gmail.com` if you're interested. Pull Requests are welcome! 

# Thanks & Credit
[Brian White](https://github.com/mscdex) for his stellar work on the [Busboy Package](https://github.com/mscdex/busboy) and the [connect-busboy Package](https://github.com/mscdex/connect-busboy)

---
_Source: https://npm.io/package/@odczynflnpm/mollitia-praesentium-deserunt · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
