Hi Konstantin Khomoutov:
    Thanks so much for your great support. It works.

BR Robert

2017-02-07 18:24 GMT+08:00 Konstantin Khomoutov <
[email protected]>:

> On Tue, 7 Feb 2017 02:01:51 -0800 (PST)
> Robert Hsiung <[email protected]> wrote:
>
> >     I tried to upload file via SFTP,but the file size is zero when it
> > is done.Any suggestions? Thanks so much.
>
> [...]
> >     srcFile, err := os.Open("F:/NCA/20161027-1.csv")
> [...]
> >     dstFile, err := server.Create("/root/20161027-1.csv")
> [...]
> >     // Copy the file
> >     dstFile.WriteTo(srcFile)
>
> As I read [1], sftp.File.WriteTo() writes the instance it's called on
> to the supplied writer (implementing io.Writer), so calling
>
>   dstFile.WriteTo(srcFile)
>
> is like saying "Hey, dstFile, please write yourself to srcFile",
> which is the reverse to what you're apparently after.
>
> So my take is that you should use
>
>   io.Copy(dstFile, srcFile)
>
> instead.
>
> 1. https://github.com/pkg/sftp/blob/master/client.go#L743
>

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to