@zenweb/upload
v5.0.0
Published
Zenweb Upload module
Downloads
805
Maintainers
Readme
ZenWeb Upload module
文件上传表单支持
演示
import { mapping } from 'zenweb';
import { Upload, UploadHelper } from '@zenweb/upload';
export class Controller {
@mapping({ path: '/', method: 'POST' })
post1(upload: Upload) {
console.log(upload.fields); // 表单字段数据
console.log(upload.files); // 文件列表
}
@mapping({ path: '/', method: 'POST' })
post2(upload: UploadHelper) {
console.log(upload.get({ age: '!int' })); // 表单字段数据转换&校验
console.log(upload.file('name')); // 取得单个文件
}
}
可注入对象
singleton
- UploadOption
request
- Upload
- UploadHelper
全局模式
| 方法 | 功能 | | ----- | ---- | | $getUpload() | 取得当前请求 Upload | $getUploadHelper() | 取得当前请求 UploadHelper