node-uploadx

0

Описание

Node.js middleware for handling resumable uploads

Языки

  • TypeScript96,2%
  • JavaScript3,8%
README.md

node-uploadx

npm version Build status commits since latest release

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:

Separate modules can also be used to save disk space and for faster installation process.:

  • core module:

  • S3 storage support:

♨️ Usage

Express example:

Please navigate to the examples for more.

🛠️ Options

Some available options: :

optiontypedefault valuedescription
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
logLevel
LogLevel
"none"
Set built-in logger severity level

📝 Logging

The library uses

for structured logging. Set
logLevel
to enable it, or configure LogTape directly for advanced use cases.

See examples/express-logtape.ts for a complete example.

🔑 Environment Variables

UPLOADX_SECRET
- Secret for salting file/user IDs (set to random string in production).

Contributing

If you'd like to contribute, please fork the repository and make changes as you'd like. Pull requests are welcome!

License

MIT