Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- app.post('/api/blk/pedazosDeInfo',(req,res) => {
- ruta = req.body.ruta;
- informacion = req.body.informacion;
- offset = parseInt( req.body.offset );
- ruta = _path.join(__dirname, '..','..' ,ruta);
- buffer = new Buffer(informacion);
- fsExtra.ensureFile(ruta, err => {// A: file has now been created, including the directory it is to be placed in
- if (err) console.log(err) // => null
- fs.open(ruta, 'r+', function(err, fd) {
- if (err) {
- throw 'error opening file: ' + err;
- }
- fs.write(fd, buffer, 0, buffer.length, offset, function(err) {
- if (err) throw 'error writing file: ' + err;
- fs.close(fd, function() {
- res.send('file written');
- })
- });
- });
- })
- })
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement