fix asyncftpclient examples [ci skip]
This commit is contained in:
parent
8c93c692b9
commit
5484352d26
1 changed files with 29 additions and 29 deletions
|
|
@ -21,13 +21,13 @@
|
||||||
## In order to begin any sort of transfer of files you must first
|
## In order to begin any sort of transfer of files you must first
|
||||||
## connect to an FTP server. You can do so with the ``connect`` procedure.
|
## connect to an FTP server. You can do so with the ``connect`` procedure.
|
||||||
##
|
##
|
||||||
## .. code-block::nim
|
## .. code-block::nim
|
||||||
## import asyncdispatch, asyncftpclient
|
## import asyncdispatch, asyncftpclient
|
||||||
## proc main() {.async.} =
|
## proc main() {.async.} =
|
||||||
## var ftp = newAsyncFtpClient("example.com", user = "test", pass = "test")
|
## var ftp = newAsyncFtpClient("example.com", user = "test", pass = "test")
|
||||||
## await ftp.connect()
|
## await ftp.connect()
|
||||||
## echo("Connected")
|
## echo("Connected")
|
||||||
## waitFor(main())
|
## waitFor(main())
|
||||||
##
|
##
|
||||||
## A new ``main`` async procedure must be declared to allow the use of the
|
## A new ``main`` async procedure must be declared to allow the use of the
|
||||||
## ``await`` keyword. The connection will complete asynchronously and the
|
## ``await`` keyword. The connection will complete asynchronously and the
|
||||||
|
|
@ -41,16 +41,16 @@
|
||||||
## working directory before you do so with the ``pwd`` procedure, you can also
|
## working directory before you do so with the ``pwd`` procedure, you can also
|
||||||
## instead specify an absolute path.
|
## instead specify an absolute path.
|
||||||
##
|
##
|
||||||
## .. code-block::nim
|
## .. code-block::nim
|
||||||
## import asyncdispatch, asyncftpclient
|
## import asyncdispatch, asyncftpclient
|
||||||
## proc main() {.async.} =
|
## proc main() {.async.} =
|
||||||
## var ftp = newAsyncFtpClient("example.com", user = "test", pass = "test")
|
## var ftp = newAsyncFtpClient("example.com", user = "test", pass = "test")
|
||||||
## await ftp.connect()
|
## await ftp.connect()
|
||||||
## let currentDir = await ftp.pwd()
|
## let currentDir = await ftp.pwd()
|
||||||
## assert currentDir == "/home/user/"
|
## assert currentDir == "/home/user/"
|
||||||
## await ftp.store("file.txt", "file.txt")
|
## await ftp.store("file.txt", "file.txt")
|
||||||
## echo("File finished uploading")
|
## echo("File finished uploading")
|
||||||
## waitFor(main())
|
## waitFor(main())
|
||||||
##
|
##
|
||||||
## Checking the progress of a file transfer
|
## Checking the progress of a file transfer
|
||||||
## ========================================
|
## ========================================
|
||||||
|
|
@ -59,20 +59,20 @@
|
||||||
## by specifying a ``onProgressChanged`` procedure to the ``store`` or
|
## by specifying a ``onProgressChanged`` procedure to the ``store`` or
|
||||||
## ``retrFile`` procedures.
|
## ``retrFile`` procedures.
|
||||||
##
|
##
|
||||||
## .. code-block::nim
|
## .. code-block::nim
|
||||||
## import asyncdispatch, asyncftpclient
|
## import asyncdispatch, asyncftpclient
|
||||||
##
|
##
|
||||||
## proc onProgressChanged(total, progress: BiggestInt,
|
## proc onProgressChanged(total, progress: BiggestInt,
|
||||||
## speed: float): Future[void] =
|
## speed: float): Future[void] =
|
||||||
## echo("Uploaded ", progress, " of ", total, " bytes")
|
## echo("Uploaded ", progress, " of ", total, " bytes")
|
||||||
## echo("Current speed: ", speed, " kb/s")
|
## echo("Current speed: ", speed, " kb/s")
|
||||||
##
|
##
|
||||||
## proc main() {.async.} =
|
## proc main() {.async.} =
|
||||||
## var ftp = newAsyncFtpClient("example.com", user = "test", pass = "test")
|
## var ftp = newAsyncFtpClient("example.com", user = "test", pass = "test")
|
||||||
## await ftp.connect()
|
## await ftp.connect()
|
||||||
## await ftp.store("file.txt", "/home/user/file.txt", onProgressChanged)
|
## await ftp.store("file.txt", "/home/user/file.txt", onProgressChanged)
|
||||||
## echo("File finished uploading")
|
## echo("File finished uploading")
|
||||||
## waitFor(main())
|
## waitFor(main())
|
||||||
|
|
||||||
|
|
||||||
import asyncdispatch, asyncnet, nativesockets, strutils, parseutils, os, times
|
import asyncdispatch, asyncnet, nativesockets, strutils, parseutils, os, times
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue