SHARE
TWEET

Untitled

a guest Sep 20th, 2019 83 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. app.post('/api/blk/pedazosDeInfo',(req,res) => {
  2.     ruta = req.body.ruta;
  3.     informacion = req.body.informacion;
  4.     offset = parseInt( req.body.offset );
  5.    
  6.     ruta = _path.join(__dirname, '..','..' ,ruta);
  7.     buffer = new Buffer(informacion);
  8.  
  9.     fsExtra.ensureFile(ruta, err => {// A: file has now been created, including the directory it is to be placed in
  10.         if (err) console.log(err) // => null
  11.        
  12.         fs.open(ruta, 'r+', function(err, fd) {
  13.             if (err) {
  14.                 throw 'error opening file: ' + err;
  15.             }
  16.             fs.write(fd, buffer, 0, buffer.length, offset, function(err) {
  17.                 if (err) throw 'error writing file: ' + err;
  18.                 fs.close(fd, function() {
  19.                     res.send('file written');
  20.                 })
  21.             });
  22.         });
  23.     })
  24. })
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top