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
This commit is contained in:
Julien Laffaye 2013-05-08 17:39:05 +02:00
parent 3a7f65cd20
commit ebf946ada5

12
ftp.go
View File

@ -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