Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
30
Task/FTP/Nim/ftp.nim
Normal file
30
Task/FTP/Nim/ftp.nim
Normal file
|
|
@ -0,0 +1,30 @@
|
|||
import asyncdispatch, asyncftpclient
|
||||
|
||||
const
|
||||
Host = "speedtest.tele2.net"
|
||||
Upload = "upload"
|
||||
File = "1KB.zip"
|
||||
|
||||
proc main {.async.} =
|
||||
|
||||
# Create session and connect.
|
||||
let ftp = newAsyncFtpClient(Host, user = "anonymous", pass = "anything")
|
||||
await ftp.connect()
|
||||
echo "Connected."
|
||||
echo await ftp.send("PASV") # Switch to passive mode.
|
||||
|
||||
# Change directory and list its contents.
|
||||
await ftp.cd(Upload)
|
||||
echo "Changed to directory: ", Upload
|
||||
echo "Contents of directory: ", Upload
|
||||
for file in await ftp.listDirs():
|
||||
echo " ", file
|
||||
|
||||
# Download a file.
|
||||
await ftp.cd("/")
|
||||
echo "Returned to root directory."
|
||||
await ftp.retrFile(file = File, dest = File)
|
||||
echo "Downloaded file: ", File
|
||||
echo await ftp.send("QUIT") # Disconnect.
|
||||
|
||||
waitFor main()
|
||||
Loading…
Add table
Add a link
Reference in a new issue