/scala-ftp

FTP library for Scala

Primary LanguageScalaOtherNOASSERTION

Scala FTP

A small library for working with FTP in Scala

object E {

	private val client: FTP = FTPClient() // create a new FTP client instance

	def downloadFileExample() : Unit = {

		client.connectWithAuth("ftp.mozilla.org", "anonymous", "")

		client.cd("pub")

		//Download file
		if (client.filesInCurrentDirectory.contains("README")) {
			client.downloadFile("README")
		}

		client.disconnect()

	}

	def uploadFileExample() : Unit = {

		client.connectWithAuth("ftp.mozilla.org", "anonymous", "")

		client.cd("pub")

		//Upload file
		if (client.filesInCurrentDirectory.contains("README")) {
			val fileStream: InputStream = ftp.downloadFileStream("README")
			client.uploadFile("README_REUPLOADED", fileStream)
		}

		client.disconnect()

	}

}