Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

529
Views
nodos ssh2 | subir archivo a sftp | Error: Permiso denegado en 101

Al intentar cargar un archivo en el servidor sftp, aparece un error de permiso denegado. La misma operación funciona si el archivo se transfiere a través de FilezIlla.

 const UploadFiletoFTP = () => { let Client = require('ssh2').Client; var connSettings = { host: 'abc.com', port: 22, username: 'user', password: 'pass', }; var conn = new Client(); conn .on('ready', function () { conn.sftp(function (err, sftp) { try { if (err) { console.log(err); throw 'error ' + err; } console.log('connected'); var fs = require('fs'); // Use node filesystem var readStream = fs.createReadStream( require('path').join( __dirname + '/audio/test_data_25_05_2022_09_58_00.zip' ) ); sftp.readdir( 'speech/non-english', function (err, list) { if (err) throw err; // List the directory in the console console.dir(list); // Do not forget to close the connection, otherwise you'll get troubles conn.end(); } ); var writeStream = sftp.createWriteStream('SpeechIQ', { flags: 'a', // w - write and a - append encoding: null, // use null for binary files mode: 0o666, // mode to use for created file (rwx) }); writeStream.on('close', function () { console.log('- file transferred succesfully'); }); writeStream.on('end', function () { console.log('sftp connection closed'); conn.end(); }); readStream.pipe(writeStream); } catch (err) { console.error(err); } }); }) .connect(connSettings); }; UploadFiletoFTP();

Cuando se ejecuta el código anterior, aparece el siguiente error:

 events.js:377 throw er; // Unhandled 'error' event ^ Error: Permission denied at 101 Emitted 'error' event on Client instance at: . . . . code: 3 }

Por favor avise si me estoy perdiendo algo.

El siguiente fragmento enumera los archivos en el directorio, pero el flujo de escritura no funciona.

 sftp.readdir( 'speech/non-english', function (err, list) { if (err) throw err; // List the directory in the console console.dir(list); // Do not forget to close the connection, otherwise you'll get troubles conn.end(); } );
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Tuve que dar el nombre del archivo al que se deben cargar los datos.

 var writeStream = sftp.createWriteStream('SpeechIQ/filename.zip', { flags: 'a', // w - write and a - append encoding: null, // use null for binary files mode: 0o666, // mode to use for created file (rwx) });
about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!