ftp.put()
ftp.put(url,data,mode,[user],[password]) → number
FTP File Write / Append
Write to a file on a ftp server.
Mode argument determines whether the file is overwritten or appended to. If a file does not exist it will automatically be created
Useful for uploading test results, etc to a remote server.
Testing
Run python3 -m pyftpdlib -w -p2121 -u logger -P secret on a local linux workstation to spin up a FTP server instance for testing
Requires installing pyftpdlib with pip install pyftpdlib or sudo apt-get install python3-pyftpdlib etc.
Security Considerations
FTP is considered an insecure file transfer protocol, use only on a private or restricted network.
Arguments
| Name | Type | Required | Default | Description |
|---|---|---|---|---|
| url | string | yes | — | e.g. "10.0.0.1:21/log.txt" |
| data | string | yes | — | payload |
| mode | number | optional | 0 | 0 = write, 1 = append |
| user | string | optional | — | anonymous |
| password | string | optional | — | default = blank |
Returns
number
0 = success, >0 = error code
Example
let res = ftp.put("172.16.220.220:2121/voltage.log","Hello World!");