smallfish / ftp Goto Github PK
View Code? Open in Web Editor NEWFTP Client For Go(lang)
FTP Client For Go(lang)
If my user doesn't have write permissions, occurs this:
<cmd>
<code> 220
<message> (vsFTPd 2.3.5)
<cmd> USER xxxxxxxxxx
<code> 331
<message> Please specify the password.
<cmd> PASS yyyyyyyyyyyyyy
<code> 230
<message> Login successful.
<cmd> PASV
<code> 227
<message> Entering Passive Mode (127,0,0,1,39,156).
<cmd> STOR hola.go
<code> 550
<message> Permission denied.
<response> OK
And the program don't exits. How can I terminate the program if un error occurs, or after a timeout?
I tried to add this (after ftp.Stor("hola.go", b)):
if ftp.Code == 550 {
fmt.Println("error: permissions failure")
os.Exit(-1)
}
but it does not work.. :(
tia
ftp.go | 7 +++++--
1 file changed, 5 insertions(+), 2 deletions(-)
diff --git a/ftp.go b/ftp.go
index d15c962..d88b6d9 100644
--- a/ftp.go
+++ b/ftp.go
@@ -32,10 +32,13 @@ func (ftp *FTP) debugInfo(s string) {
func (ftp *FTP) Connect(host string, port int) {
addr := fmt.Sprintf("%s:%d", host, port)
return
func (ftp *FTP) Login(user, passwd string) {
i can't upload image into ftp
func Uper(w http.ResponseWriter , r _http.Request) {
ftp := new(ftp.FTP)
// debug default false
ftp.Debug = true
ftp.Connect(_ftp, 21)
// login
ftp.Login(*us, *ps)
if ftp.Code == 530 {
fmt.Println("error: login failure")
}
// pwd
ftp.Pwd()
fmt.Println("code:", ftp.Code, ", message:", ftp.Message)
// make dir
ftp.Request("TYPE I")
// stor file
bs := ioutil.ReadFile("./img_temp/myimage.png")
ftp.Stor("/images/myimage.png", bs)
ftp.Quit()
result on command line :
<cmd>
<code> 220
<message> FTP Server ready.
<cmd> USER [myusername_secret]
<code> 331
<message> Password required for [myuser_secret]
<cmd> PASS [mypassword_secret]
<code> 230
<message> User [myuser_secret] logged in.
<cmd> PWD
<code> 257
<message> "/" is the current directory
code: 257 , message: "/" is the current directory
<cmd> TYPE I
<code> 200
<message> Type set to I
<cmd> PASV
<code> 227
<message> Entering Passive Mode (79,127,127,81,166,78).
i can't see error in this result !
all things ok !
upload success but image is bad !
image size before upload : 398724 byte And after upload : 0 byte !!!
why? how solved this problem?
$ go get github.com/smallfish/ftp.go
stat github.com/smallfish/ftp.go: no such file or directory
This is explained here -- they have apparently decided to change things so that project names can't end with ".go".
So, if you could rename this project from ftp.go
to something else, like ftp
or ftpgo
or ftp_go
, that would be great.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.