Uploading a file to an ftp server in node.js

I am trying to upload a file on an ftp server using node.js as below -

I use the library https://github.com/sergi/jsftp

var fs = require('fs'); var Ftp = new JSFtp({ host: "ftp.some.net", port: 21, // defaults to 21 user: "username", // defaults to "anonymous" pass: "pass", debugMode: true // defaults to "@anonymous" }); 

File Download -

 exports.UploadToFtP = function (req, res) { Ftp.put('public/Test.html', '/Test/index.html', function (err) { if (!err) res.send(200); else res.send(err); }); }; 

I tried to upload the file using this method above and it answers me with 200 OK . But there are no files on the server. Should this do something with server connection time? Why does this not write the file to the server?

+8
source share
1 answer

If debugging mode is enabled, the jsftp instance will generate jsftp_debug events.

To respond to printing all debugging events, we will listen to debugging messages as follows:

 Ftp.on('jsftp_debug', function(eventType, data) { console.log('DEBUG: ', eventType); console.log(JSON.stringify(data, null, 2)); }); 
0
source

Source: https://habr.com/ru/post/973092/


All Articles