Wednesday, 3 May 2017

Reading buffer data from uploaded file in NodeJS

I am uploading a file using 'express' module. I have to read the EXIF data of the uploaded image using node-exif. I do not want to store the file on disk and the above module support reading EXIF data from buffer. I need to read the buffer data from the uploaded image. Here is the upload code:

var express = require('express');
var app = express();
var fs = require('fs');
var multiparty = require("multiparty");

module.exports.UploadImage = function (req, res, next) {
    // Handle request as multipart  
    if (!req.files)
        return res.status(400).send('No files were uploaded.');  

    var sampleFile = req.files.uploadedFile;
    //Here I need to have the buffer.
    res.send('Done!');
}

Can someone help me getting the buffer data as I am very new to Node universe?



via User2682

No comments:

Post a Comment