I'm getting FTP_NO_SUCH_FILE_OR_DIRECTORY as an er...
# general
m
I'm getting FTP_NO_SUCH_FILE_OR_DIRECTORY as an error
l
are you passing directory parameter on createConnection function?
m
Yes
message has been deleted
l
I think it’s missing directory property… try to change to directory : directory
m
I changed, but the error persists
b
fair chance that you are trying to use the directory parameter too many times
your code looks like it would only need to specify it once, unless your folder structure really has the same folder names for different folders
m
@battk I was testing, my original code connect directly in the folder I'm going to upload the file and in the upload statement I wasn't informing the directory
The function responsible for connection:
const _connectionSFTP = (record) => {
let isSftp = record.getValue('custrecord_mvc_is_sftp');
let keyId = record.getValue('custrecord_mvc_sftp_key');
let url = record.getValue('custrecord_mvc_ftp_address');
let port = record.getValue('custrecord_mvc_ftp_port');
let username = record.getValue('custrecord_mvc_integration_user');
let hostKey = record.getValue('custrecord_mvc_sftp_host_key');
let directory = record.getValue('custrecord_mvc_ftp_folder');
log.debug('Establishing SFTP connection...');
try {
const connection = sftp.createConnection({
url: url,
keyId: keyId,
hostKey: hostKey,
username: username,
port: eval(port),
hostKeyType: 'rsa',
directory: directory,
});
log.debug('Connected successfully');
return connection;
} catch(error) {
_sendErrorEmail('Falha ao conectar com o servidor de SFTP');
log.debug('error', error)
throw new Error(Falha ao conectar com o servidor de SFTP);
}
};
b
which line is throwing the error
m
The error is thrown when I try to perform the upload.
connection.upload({
//directory,
file: fileObj,
filename: 'af.txt',
replaceExisting: true
});
b
are you sure it isnt
Copy code
let objConnection = connection.list({
      path: directory
    });
m
Yes, I left a testing file in the remote folder called test.txt, I'm passing the remote directory in the connection statement, I'm listing the '/' folder, that is the '/' relative to the connected directory, when I log the objConnection variable, I can see the test.txt there
I think the problem could be related with the file I'm trying to upload, I even thought It could be because the file was only stored in memory, so I first stored the file in a folder, loaded the file in another variable and tried to upload, but the error was the same.
The server log
b
doesnt sound like you even need a directory
make sure that the user has permission to replace the file
m
Man, I'm almost thinking the upload feature is bugged, I can download a file, store in a variable, store in the file cabinet and then when I try to upload the same file I had just downloaded, I can't