func (f *FTP) Upload(job types.Job) error {
	log.Info("uploading files to FTP: ", job.Destination)
	defer log.Info("upload complete")
	filelist := []string{}
	filepath.Walk(path.Dir(job.LocalSource)+"/dst", func(path string, f os.FileInfo, err error) error {
		if isDirectory(path) {
			return nil
		}
		filelist = append(filelist, path)
		return nil
	})
	f.uploadDir(filelist, job)
	return nil
}
Upload uploads a file to FTP.
package net
import (
	"bufio"
	"io"
	"net/textproto"
	"net/url"
	"os"
	"path"
	"path/filepath"
	"time"
	"github.com/alfg/openencoder/api/types"
	"github.com/jlaffaye/ftp"
)
const (
	ErrorFileExists = "Can't create directory: File exists"
)
type FTP struct {
	Addr     string
	Username string
	Password string
	Timeout  time.Duration
}
func NewFTP(addr string, username string, password string) *FTP {
	return &FTP{
		Addr:     addr,
		Username: username,
		Password: password,
		Timeout:  5,
	}
}
func (f *FTP) Download(job types.Job) error {
	log.Info("downloading from FTP: ", job.Source)
	c, err := ftp.Dial(f.Addr, ftp.DialWithTimeout(f.Timeout*time.Second))
	if err != nil {
		log.Error(err)
		return err
	}
	err = c.Login(f.Username, f.Password)
	if err != nil {
		log.Error(err)
		return err
	}
	resp, err := c.Retr(job.Source)
	if err != nil {
		log.Error(err)
		return err
	}
	defer resp.Close()
	outputFile, _ := os.OpenFile(job.LocalSource, os.O_WRONLY|os.O_CREATE, 0644)
	defer outputFile.Close()
	reader := bufio.NewReader(resp)
	p := make([]byte, 1024*4)
	for {
		n, err := reader.Read(p)
		if err == io.EOF {
			break
		}
		outputFile.Write(p[:n])
	}
	if err := c.Quit(); err != nil {
		log.Error(err)
		return err
	}
	return err
}