mscdex / node-ftp

An FTP client module for node.js
MIT License
1.13k stars 243 forks source link

Error: Compression not supported #231

Open ahmedtamseer opened 5 years ago

ahmedtamseer commented 5 years ago

I am using FTP version of 0.3.10. I tried to upload a file into FTP server. My connection is successful. But I am getting below error.

{ Error: Compression not supported at makeError (/server/node_modules/ftp/lib/connection.js:1067:13) at Object.cb (/server/node_modules/ftp/lib/connection.js:973:21) at Parser. (/server/node_modules/ftp/lib/connection.js:113:22) at emitTwo (events.js:126:13) at Parser.emit (events.js:214:7) at Parser._write (/server/node_modules/ftp/lib/parser.js:59:10) at doWrite (_stream_writable.js:397:12) at writeOrBuffer (_stream_writable.js:383:5) at Parser.Writable.write (_stream_writable.js:290:11) at Socket.ondata (/server/node_modules/ftp/lib/connection.js:273:20) at emitOne (events.js:116:13) at Socket.emit (events.js:211:7) at addChunk (_stream_readable.js:263:12) at readableAddChunk (_stream_readable.js:250:11) at Socket.Readable.push (_stream_readable.js:208:10) at TCP.onread (net.js:597:20) code: 504 }

Below is the code I tried

async function sendFile(){
        const ftp_con = await getFtp().catch(err => {
                console.log('err', err)
        });

        let rs = fs.createReadStream('images/' + name_tiff);

        ftp_con.put(rs, '/incoming/' + name_tiff, true, (err) => {
              if (err) {
                    console.log(err) // error is generated here
               }
     })
}

function getFtp() {
    return new Promise((resolve, reject) => {
        try {
            const c = new ftp();
            c.connect({
                host: 'remote.com',
                port: 21,
                user: "user123",
                password: "user123"
            });
            c.on('ready', function () {
                console.log('connection successful.',);
                resolve(c);
            });

            c.on('error', function (err) {
                console.log("err", err)
                reject('Something went wrong while connecting ftp');
            })
        } catch (error) {
            reject('Something went wrong while connecting ftp');
        }
    })
}

I looked in stack overflow, but didnt had luck to find an answer. Am I doing any wrong here?

Node v8.11.3 ftp: 0.3.10

ahmedtamseer commented 5 years ago

If i change compress value to false it will work. why uploading is not working with compression true?

async function sendFile(){
        const ftp_con = await getFtp().catch(err => {
                console.log('err', err)
        });

        let rs = fs.createReadStream('images/' + name_tiff);

        ftp_con.put(rs, '/incoming/' + name_tiff, false, (err) => { // I have changed true to false
              if (err) {
                    console.log(err) // error is generated here
               }
     })
}
Lianecx commented 2 years ago

Same error here. Debug logs show this:

[connection] PASV socket connected
[connection] > 'MODE Z'
[connection] < "501 'MODE Z' unrecognized transfer mode\r\n"
[parser] < "501 'MODE Z' unrecognized transfer mode\r\n"
[parser] Response: code=501, buffer="'MODE Z' unrecognized transfer mode"