Logic Machine Forum
FTPS example - Printable Version

+- Logic Machine Forum (https://forum.logicmachine.net)
+-- Forum: LogicMachine eco-system (https://forum.logicmachine.net/forumdisplay.php?fid=1)
+--- Forum: Scripting (https://forum.logicmachine.net/forumdisplay.php?fid=8)
+--- Thread: FTPS example (/showthread.php?tid=1002)

Pages: 1 2


RE: FTPS example - Kilogica - 13.03.2024

you can see in the image that the two backups are totally different.
the before was done with the old script.
the after with the new.
Intuitively something is missing from the after


RE: FTPS example - ferrim - 20.03.2024

Hi all,
same problem here with FTPS, file uploaded but 0 K

FTP upload error: closed

HW: LM5 Lite (i.MX6)
SW: 20230607

Any tips?

Code:
host = 'xxx'
user = 'xxx'
pass = 'xxx'

path = '/backup' .. os.date('%Y-%m-%d') .. '.gz'

ftp = require('socket.ftp')
ltn12 = require('ltn12')
webrequest = require('webrequest')
data = webrequest('general', 'backup')

res, err = ftp.put({
  host = host,
  user = user,
  password = pass,
  secure = true,     -- without this: FTP upload error: 530 Non-anonymous sessions must use encryption.
  datasecure = true, -- without this: FTP upload error: 522 Data connections must be encrypted.
  type = "a",        -- no luck with type = "a" or type = "i"
  argument = path,
  source = ltn12.source.string(data)
})

if not res then
  alert('FTP upload error: %s', tostring(err))
end



RE: FTPS example - admin - 20.03.2024

Check FTP server logs and try removing / from the file path.


RE: FTPS example - ferrim - 20.03.2024

thanks Admin,
I have already tried removing / from file path but no change.

I don't manage the FTP server but I can try asking for the log...


RE: FTPS example - ferrim - 22.03.2024

This is the server side log.

The guy who manages the FTP server didn't give me much information but it seems that by putting require_ssl_reuse=NO in the vsftpd.conf configuration file and maybe some firewall tweaks, the backup file is entirely transferred but always with this error: 426 Failure reading network stream.

Now if I try to send a 2 MB .csv file with this code, I always get a file truncated to multiples of 8192 and I need advice on how to correctly send a file via FTPS.

thanks for your patience

Code:
-- ...
data = io.readfile('filename.csv')
  path = ('/' .. filename)
  res, err = ftp.put({
  host = host,
  user = user,
  password = pass,
  argument = path,
  type = "a",
  secure = true,
  datasecure = true,
  source = ltn12.source.string(data)
  })



RE: FTPS example - admin - 22.03.2024

Try adding reusesession = true, to the parameters table.


RE: FTPS example - ferrim - 22.03.2024

Ignoring the 426 error for now,
with require_ssl_reuse=NO inserted in the server configuration file vsftpd.conf the backup file is transferred entirely.

Now I need to send some 2 MB .csv files (or even a compressed ones) with the above code but I always get corrupted files as they are truncated to multiples of 8192 and I don't understand why.
No problem with smaller files