示例#1
0
文件: ftp.go 项目: kpawlik/exportms
func (f *FTP) SendFile(remoteDir, remoteFile, localFile string) (err error) {
	var (
		file *os.File
		ftp  *goftp.FTP
	)
	if ftp, err = goftp.Connect(f.host); err != nil {
		return
	}
	defer ftp.Close()
	if err = ftp.Login(f.user, f.pass); err != nil {
		return
	}
	if file, err = os.Open(localFile); err != nil {
		return
	}
	defer file.Close()
	if f.testMode {
		return
	}
	if err = ftp.Mkd(remoteDir); err != nil {
		return
	}
	if err = ftp.Cwd(remoteDir); err != nil {
		return
	}
	ftp.Stor(remoteFile, file)

	return
}
示例#2
0
func MakeBuildDir(ftp *goftp.FTP, dir string) {
	var err error
	if err = ftp.Mkd(dir); err != nil {
		panic(err)
	}
}