Hi folks, I’m trying to upload a file in meteor using HTTP POST
method and enctype="multipart/form-data"
I tried with WebApp
but getting undefined file property under request object
WebApp.connectHandlers.use("/api/v1/upload", function(req, res, next) {
console.log(req.files); //undefined
console.log(req.file); //undefined
console.log(req);
})
I also tried with multer
and Picker
but no luck.
const _multerInstanceConfig = { dest: '/tmp' }; // Temp dir for multer
const _multerInstance = multer(_multerInstanceConfig);
Picker.middleware(_multerInstance.single('photo'));
Picker.route('/api/v1/upload', function(params, req, res, next) {
console.log(req.files); //undefined
console.log(req.file); //undefined
console.log(req);
})
Am I missing something here? not sure.
Also, I don’t want to upload files using base64 data string via DDP as it very slow.
PS: I need to upload images via native Android/iOS clients.