This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
fs.appendFile('myfile.txt', 'this content goes at end of the file', function(err){ | |
if(err) { | |
console.log('Error is thrown', err); throw err; | |
} | |
console.log('data is appended !!'); | |
}) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
fs = require("fs"); | |
path = "data/myfile.txt"; | |
data = "This content is written from Node program"; | |
result =fs.writeFileSync(path, data); | |
console.log('written contents are : ' + result); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
fs = require("fs"); | |
path = "myfile.txt"; | |
data = "This content is written from Node program"; | |
fs.writeFile(path, data, function(error){ | |
if error | |
console.error("error: " + error.message); | |
else | |
console.log("Successful Write to " + path); | |
}) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
res= <destination file stream>; // It can be standard io, another file stream, etc | |
readStream = fs.createReadStream(filename); | |
readStream.on('open', function(){ | |
readStream.pipe(res); | |
}); | |
readStream.on('error', function(err){ | |
res.end(err); | |
}); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//read it synchronously | |
content= fs.readFileSync('package.json', 'utf-8'); | |
console.log(content); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
fs= require(‘fs’) | |
//read it asynchronously | |
fs.readFile('package.json', function(err, res){ | |
if(err){ | |
console.log('Error while reading the file content '); | |
} | |
console.log('file contents- ' + res) | |
}) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
meteor add <package-name> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[ | |
{ | |
"raw": "This is some text to demonstrate how a recursive parser works it has ", | |
"data": "This is some text to demonstrate how a recursive parser works it has ", | |
"type": "text" | |
}, | |
{ | |
"raw": "b", | |
"data": "b", | |
"type": "tag", |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var fs = require('fs') | |
fs.readFile('app.js', errorHandler(function (content) { | |
console.log('File contents are ' + content) | |
}) | |
) | |
function errorHandler(callback) { | |
return function (err, result) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"Version":"2012-10-17", | |
"Statement":[ | |
{ | |
"Sid":"AddPerm", | |
"Effect":"Allow", | |
"Principal": "*", | |
"Action":["s3:GetObject"], | |
"Resource":["arn:aws:s3:::ExampleBucket/*"] | |
} |