예제 #1
0
파일: main.go 프로젝트: MoZhonghua/easyftp
func downloadFile(c *easyftp.Client, from string, to string) {
	w, err := os.Create(to)
	if err != nil {
		fmt.Println("failed to open download dest file:", err)
		return
	}
	defer w.Close()

	r, err := c.Retr(from)
	if err != nil {
		fmt.Println("failed to open remote file:", err)
		return
	}
	defer r.Close()
	io.Copy(w, r)
}
예제 #2
0
파일: main.go 프로젝트: MoZhonghua/easyftp
func abortedDownloadFile(c *easyftp.Client, from string, to string) {
	w, err := os.Create(to)
	if err != nil {
		fmt.Println("failed to open download dest file:", err)
		return
	}
	defer w.Close()

	r, err := c.Retr(from)
	if err != nil {
		fmt.Println("failed to open remote file:", err)
		return
	}
	err = r.Close()
	if err != nil {
		fmt.Println("aborted file downloading:", err)
		return
	}
	// We close the connection without reading anything
	// io.Copy(w, r)
}