From ebf946ada576fdf53d9562e5ca16ccc739eb7971 Mon Sep 17 00:00:00 2001 From: Julien Laffaye Date: Wed, 8 May 2013 17:39:05 +0200 Subject: [PATCH] Switch to binary mode once logged-in. Data transfer in binary mode works for both ASCII and binary (such as JPEG images) files. Therefore it should be the default. Fixes #3 --- ftp.go | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/ftp.go b/ftp.go index c688832..ac20af4 100644 --- a/ftp.go +++ b/ftp.go @@ -61,7 +61,17 @@ func (c *ServerConn) Login(user, password string) error { } _, _, err = c.cmd(StatusLoggedIn, "PASS %s", password) - return err + if err != nil { + return err + } + + // Switch to binary mode + _, _, err = c.cmd(StatusCommandOK, "TYPE I") + if err != nil { + return err + } + + return nil } // Enter extended passive mode