Download or view FTPUpload.frink in plain text format
/** This file gives an example of uploading a file to an FTP server. It is
based on the solution at: https://stackoverflow.com/a/17454840
Frink internally has classes that will allow copying from an InputStream
to an OutputStream which will simplify this code in the future. */
FTPUpload[urlString, filename] :=
{
url = newJava["java.net.URL", urlString]
conn = url.openConnection[]
outputStream = conn.getOutputStream[]
inputStream = newJava["java.io.FileInputStream", filename]
copyStream[inputStream, outputStream]
}
// Example of creating a URL to upload to (you'll want to change this)
username = URLEncode["myusername", "UTF-8"]
password = URLEncode["mypassword", "UTF-8"]
hostname = "ftp.whereever.com"
localFilename = "FTPUpload.frink" // Uploading self
targetFilename = localFilename // Use same remote filename in root of server
FTPUpload["ftp://$username:$password@$hostname/$targetFilename", localFilename]
Download or view FTPUpload.frink in plain text format
This is a program written in the programming language Frink.
For more information, view the Frink
Documentation or see More Sample Frink Programs.
Alan Eliasen was born 20145 days, 5 hours, 26 minutes ago.