Awesome
node-uploadx
Resumable upload middleware for express and plain node.js. Server-side part of ngx-uploadx
⨠Features
- resumable simple/chunked uploads
- can save files to local filesystem, S3, GCS
- saving added metadata along with files
- logging and error handling
- chunks checksum verification
- file type/size/custom validations
- fixed/rolling expiration and cleanup
- extensibility (custom storages, upload protocols, etc)
đŠī¸ Installation
All-In-One with cloud storage support:
npm install node-uploadx
Separate modules can also be used to save disk space and for faster installation process.:
-
core module:
npm install @uploadx/core
-
S3 storage support:
npm install @uploadx/s3
â¨ī¸ Usage
Express example:
const express = require('express');
const { uploadx } = require('@uploadx/core');
const app = express();
app.use(
'/uploads',
uploadx({
directory: './files',
maxUploadSize: '10GB',
allowMIME: ['video/*'],
onComplete: file => console.log('Upload complete: ', file)
})
);
app.listen(3003);
Please navigate to the examples for more.
đ ī¸ Options
Some available options: :
option | type | default value | description |
---|---|---|---|
directory | string | "files" | DiskStorage upload directory |
bucket | string | "node-uploadx" | Storage bucket |
path | string | "/files" | Node http base path |
allowMIME | string[] | ["*\*"] | Allowed MIME types |
maxUploadSize | string|number | "5TB" | File size limit |
metaStorage | MetaStorage | Provide custom meta storage | |
metaStorageConfig | MetaStorageOptions | Configure metafiles storage | |
maxMetadataSize | string|number | "4MB" | Metadata size limit |
validation | Validation | Upload validation options | |
useRelativeLocation | boolean | false | Use relative urls |
filename | Function | File naming function | |
userIdentifier | UserIdentifier | Get user identity | |
onCreate | OnCreate | Callback that is called when a new upload is created | |
onUpdate | OnUpdate | Callback that is called when an upload is updated | |
onComplete | OnComplete | Callback that is called when an upload is completed | |
onDelete | OnDelete | Callback that is called when an upload is cancelled | |
onError | OnError | Customize error response | |
expiration | ExpirationOptions | Configuring the cleanup of abandoned and completed uploads | |
logger | Logger | Custom logger injection | |
logLevel | LogLevel | "none" | Set built-in logger severity level |
Contributing
If you'd like to contribute, please fork the repository and make changes as you'd like. Pull requests are welcome!