Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
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
- Host: GitHub
- URL: https://github.com/postor/express-chunk-upload
- Owner: postor
- Created: 2020-10-31T08:48:53.000Z (about 4 years ago)
- Default Branch: main
- Last Pushed: 2021-11-06T09:47:53.000Z (about 3 years ago)
- Last Synced: 2024-11-11T02:09:36.220Z (about 2 months ago)
- Topics: chunked-uploads, express, nextjs, typescript
- Language: TypeScript
- Homepage:
- Size: 151 KB
- Stars: 0
- Watchers: 3
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
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').defaultconst app = express()
app.use('/upload',getHandler({
uploadPath: __dirname+ '/uploads'
}))
```浏览器端(webpack环境) | client side(webpack)
```
const Uploader = require('express-chunk-upload/dist/Uploader').defaultlet 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',
},
},
}
```