0
私のアプリケーションからkoa.jsに基づいてノードjsサーバにファイルをアップロードしようとしています。 koa-bodyとformidableを使用して本文を解析します。ここでkoa-jsサーバにファイルをアップロードする
は私のサーバーです:
this.app.use(formidable());
this.app.use(koaBody({
formidable:{
uploadDir: __dirname + '/uploads', // directory where files will be uploaded
keepExtensions: true, // keep file extension on upload
multiples: true
},
multipart: true,
urlencoded: true,
formLimit: '5mb',
}));
this.app.use(_.post('/wish/photo/upload', async (ctx, next) => {
//ctx.body = JSON.stringify(ctx.request);
next();
}));
、これはフロントエンドに私のファイルアップロード機能である:
uploadFromPc(files, parameters){
let headers = new Headers();
let formData = new FormData();
Array.from(files).forEach(file => formData.append('photo', file));
let options = new RequestOptions({ headers: headers });
//options.params = parameters;
return this.http.post(EnvVariables.apiEndpoint + 'wish/photo/upload', formData, options)
.subscribe(response => console.log(response))
}
すべてはそれが必要となりますが、ファイルは作成されず、エラーはありません示された、何も。
アイデア?