I keep having a problem uploading a csv file. In the request, everything comes in formdata, but when I try to access the file, everything is undefined
This is my written code
Route config
export abstract class RouteConfig {
app: Application;
name: string;
constructor(app: Application, name: string) {
this.app = app;
this.name = name;
this.configureRoutes();
}
getName() {
return this.name;
}
abstract configureRoutes(): Application;
import csv routes
const upload = multer({dest: 'tmp/csv'});
export class ProductRoutes extends RouteConfig {
constructor(app: Application) {
super(app, "ProductRoutes");
}
configureRoutes() {
this.app.route('/api/products/custom-import')
.post([JWT.authenticateJWT, ProductController.importProductWithCustomFeed, upload.single('feed')]);
return this.app;
}
}
const fileContents: Any[] = await readFile((req as any).feed.path);
res.json(fileContents);
controller
Everything seems correct to me, but I don't understand where it comes from. The only problem I see is not from that upload.single through which I indicate the path But I don't know..