Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/postor/express-chunk-upload

chunk upload with express https://www.youtube.com/watch?v=SuLQ6QhPm9o&list=PLM1v95K5B1ntVsYvNJIxgRPppngrO_X4s&index=32
https://github.com/postor/express-chunk-upload

chunked-uploads express nextjs typescript

Last synced: about 1 month ago
JSON representation

chunk upload with express https://www.youtube.com/watch?v=SuLQ6QhPm9o&list=PLM1v95K5B1ntVsYvNJIxgRPppngrO_X4s&index=32

Awesome Lists containing this project

README

        

# express-chunk-upload

基于 express 的文件上传前后端工具套件(自动分片) | chunk upload with express, uploading made easy

## 使用 | usage

服务端 | server side

```
const express = require('express')
const getHandler = require('express-chunk-upload').default

const app = express()
app.use('/upload',getHandler({
uploadPath: __dirname+ '/uploads'
}))
```

浏览器端(webpack环境) | client side(webpack)

```
const Uploader = require('express-chunk-upload/dist/Uploader').default

let loader = new Uploader({url:'/upload'})

let item = loader.upload(input.files[0],{
onProgress: progress=>console.log(progress),
onError: error=>console.log(error),
onFinish: ({ fileName }) => console.log(fileName)
})

item.start().then(fileName=>console.log(fileName))

```

Next.JS

```
// pages/api/upload.js
import getHandler from 'express-chunk-upload'
import { join } from 'path'
import { fileURLToPath } from 'url'

export default getHandler({
uploadPath: join(
fileURLToPath(import.meta.url), '..', '..', '..', 'public', 'uploads')
})

export const config = {
api: {
bodyParser: {
sizeLimit: '10mb',
},
},
}
```