Esempio n. 1
0
func uploadTestFile(fs *gowfs.FileSystem, testFile, hdfsPath string) string {
	file, err := os.Open(testFile)
	if err != nil {
		log.Fatal("Unable to find local test file: ", err)
	}
	stat, _ := file.Stat()
	if stat.Mode().IsDir() {
		log.Fatal("Data file expected, directory found.")
	}
	log.Println("Test file ", stat.Name(), " found.")

	shell := gowfs.FsShell{FileSystem: fs}
	log.Println("Sending file ", file.Name(), " to HDFS location ", hdfsPath)
	ok, err := shell.Put(file.Name(), hdfsPath, true)
	if err != nil || !ok {
		log.Fatal("Failed during test file upload: ", err)
	}
	_, fileName := path.Split(file.Name())
	log.Println("File ", fileName, " Copied OK.")
	remoteFile := hdfsPath + "/" + fileName
	ls(fs, remoteFile)

	return remoteFile
}