1<script>
2// Requiring fs module in which
3// writeFile function is defined.
4const fs = require('fs')
5
6// Data which will write in a file.
7let data = "Learning how to write in a file."
8
9// Write data in 'Output.txt' .
10fs.writeFile('Output.txt', data, (err) => {
11
12 // In case of a error throw err.
13 if (err) throw err;
14})
15</script>
1 var imagePath = path.join('/images/logo.png', 'logo.png');
2
3 if (fs.statSync(imagePath)) {
4 var bitmap = fs.readFileSync(imagePath);
5 var bufferImage = new Buffer(bitmap);
6
7 Magic = mmm.Magic;
8 var magic = new Magic(mmm.MAGIC_MIME_TYPE);
9 magic.detectFile(imagePath, function(err, result) {
10 if (err) throw err;
11 datas = [{"buffer": bufferImage, "mimetype": result, "originalname": path.basename(imagePath)}];
12 var JsonDatas= JSON.parse(JSON.stringify(datas));
13 log.notice(JsonDatas);
14 });
15 }
16