dutchcoders / goftp

Golang FTP library with Walk support.
MIT License
278 stars 99 forks source link

Possible to view progress of download? #40

Open Broham opened 6 years ago

Broham commented 6 years ago

I am attempting to pull down a fairly large file (2 GB).

I took your example and added some logging:

_, err = ftp.Retr(path, func(r io.Reader) error {

    var hasher = sha256.New()
    fmt.Println("Call copy")
    if _, err = io.Copy(hasher, r); err != nil {
        return err
    }
    fmt.Println("after copy")
    hash := fmt.Sprintf("%s %x", path, hex.EncodeToString(hasher.Sum(nil)))
    fmt.Println(hash)
        return nil

But after it logs "Call copy" it sits for quite a while. I assume this is because the file is actually downloading at this point.

I'm wondering if my assumption is correct? If so - is there any way that I can display the download progress periodically while the file is downloading?