예제 #1
0
파일: main.go 프로젝트: MoZhonghua/easyftp
func listDir(c *easyftp.Client) {
	r, err := c.List(".")
	if err != nil {
		fmt.Println("LIST: ", err)
		return
	}
	defer r.Close()
	io.Copy(os.Stdout, r)
}
예제 #2
0
파일: main.go 프로젝트: MoZhonghua/easyftp
func uploadFile(c *easyftp.Client, from string, to string) {
	r, err := os.Open(from)
	if err != nil {
		fmt.Println("failed to open upload local file:", err)
		return
	}
	defer r.Close()

	err = c.Stor(to, r)
	if err != nil {
		fmt.Println("failed to open remote file:", err)
		return
	}
}
예제 #3
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)
}
예제 #4
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)
}