I am currently using Multer to handle my image uploads and I am using multer's memory storage option to write the image to the buffer. I would like to then retrieve this image buffer and send it to an external service like Mircosoft Cognitive Services. However, whenever I send the image buffer to cognitive services, it appears that only part of the whole image buffer is sent. How do I ensure that I have read the whole image buffer into a variable first before sending it to cognitive services? My existing code looks something like this:
var multer = require('multer');
var upload = multer({ storage: multer.memoryStorage() });
//Upload route
router.route('/uploadImage')
.post(upload.single('profileImg'), function(req, res, next){
//Store image upload buffer in variable
var img = req.file.buffer;
//Send the image upload buffer stored in variable to cognitive services
request.post({
...,
body: img //Should be complete when sent to cognitive services
})
});
via Chua Bing Quan
No comments:
Post a Comment