Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

create file object node js

  var imagePath = path.join('/images/logo.png', 'logo.png');

  if (fs.statSync(imagePath)) {
     var bitmap = fs.readFileSync(imagePath);
     var bufferImage = new Buffer(bitmap);

     Magic = mmm.Magic;
     var magic = new Magic(mmm.MAGIC_MIME_TYPE);
     magic.detectFile(imagePath, function(err, result) {
          if (err) throw err;
          datas = [{"buffer": bufferImage, "mimetype": result, "originalname": path.basename(imagePath)}];
          var JsonDatas= JSON.parse(JSON.stringify(datas));
          log.notice(JsonDatas);
     });
 }
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #create #file #object #node #js
ADD COMMENT
Topic
Name
8+6 =