xyt
v1.0.3
Published
save file from http.IncomingMessage
Downloads
1
Readme
XiaoYangTouJs
- 把 request 对象(即 http.IncomingMessage)里的文件存到硬盘某处
- 一次只允许保存一个文件
如何使用
安装
$ npm install xyt
在项目中使用
const http = require('http');
const xyt = require('xyt');
const filePosition = 'C:\\static';
const fileWriter = new xyt(filePosition, 1024*1024*2); // 实例化只需要一个存储路径(绝对路径)
function handler(request, response){
fileWriter.save(request).then( fileName => {
console.log('文件已保存');
response.end(fileName);
}).catch( e => {
response.end(e.message);
});
}
http.createServer(handler).listen(1234);
待解决的问题
- save 方法提供文件配置、文件名、文件最大字节数指定