Beispiel #1
0
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)
}
Beispiel #2
0
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
	}
}
Beispiel #3
0
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)
}
Beispiel #4
0
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)
}