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
| /* | |
| * Sync all tables to database | |
| */ | |
| db.sequelize.sync({force:true}).then(function(){ | |
| console.log('DB Connection - OK'); | |
| let crypto = require('crypto'); | |
| //Lib for crypting strings | |
| let crypto = require('crypto'); | |
| //Creating my cipher, by using the key REPLACE_YOUR_KEY_HERE |
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
| <!-- This is assuming that this document will get in folder Layout, the dust file layout as it template --> | |
| {>"layout/layout" /} | |
| <!-- This variable, is responsable for get all HTML content and compile it together with the {+body /} in layout file--> | |
| {<body} | |
| <div class="row"><br></div> | |
| <main role="main" class="container"> | |
| <div class="jumbotron"> | |
| <h1><p><strong>Here it is my second dust file!</strong></p></h1> |
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
| /* | |
| * Example with one file upload | |
| * In this example, inside single() function, we use the name of the name of the element in the html | |
| * which we are sending the post, in this case, it is called file ( check line 19 of file.dust file ) | |
| */ | |
| app.post('/file', upload.single('file'),function(req, res) { | |
| //res.json(req.file); | |
| if(req.file){ | |
| //Reading the file saved in src/temp folder | |
| let fileContent = base64_encode(req.file.filename);//sendind filename which Multer gives |
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'); | |
| //Convertendo binario em arquivo | |
| function base64_decode(base64str,fileName){ | |
| var bitmap = new Buffer (base64str, 'base64'); | |
| fs.writeFileSync('src/temp/'+fileName+'',bitmap, 'binary', function (err){ | |
| if(err){ | |
| console.log('Conversao com erro'); | |
| } |
NewerOlder