예제 #1
0
func makeDir(info *SyncInfo, ftpClinet *goftp.Client, objects *[]string) {
	for _, obj := range *objects {
		path := getFtpPath(info, obj)
		var mkPath string
		for i, dir := range *path {
			mkPath += dir + "/"
			if i <= len(*path)-2 {
				ftpClinet.Mkdir(mkPath)
			}
		}
	}
}
예제 #2
0
func doUploadObject(info *SyncInfo, object string, ftpClient *goftp.Client, doUpload chan bool, uploadDone chan bool) {
	for {
		_, ok := <-doUpload
		if ok {
			ftpPath := getFtpPath(info, object)
			ftpPathStr := strings.Join(*ftpPath, "/")
			rc, err := gcloud.storageClient.Bucket(config.GsBucket).Object(object).NewReader(gcloud.ctx)
			if err != nil {
				log.Println("Get Object Read io failed.", err)
			} else {
				defer rc.Close()
				err := ftpClient.Store(ftpPathStr, rc)
				if err != nil {
					log.Println("Object store to FTP failed ", err)
				} else {
					log.Println(ftpPathStr + " stror to FTP Success.")
				}
			}
		}
		uploadDone <- true
		return
	}
}