Esempio n. 1
0
func listFiles(cmd *cobra.Command, args []string) {
	url := core.UrlHandler(ToadHost, ToadPort, "/listfiles", "")
	resp, err := http.Get(url)
	if err != nil {
		common.IfExit(err)
	}
	defer resp.Body.Close()
	b, err := ioutil.ReadAll(resp.Body)
	if err != nil {
		common.IfExit(err)
	}
	log.Warn(string(b))
}
Esempio n. 2
0
func putFiles(cmd *cobra.Command, args []string) {
	fileName := args[0]

	file, err := os.Open(fileName)
	defer file.Close()
	if err != nil {
		common.IfExit(err)
	}
	url := core.UrlHandler(ToadHost, ToadPort, "/postfile?fileName=", fileName)
	_, err = http.Post(url, "", file)
	if err != nil {
		common.IfExit(err)
	}
	log.Warn("success. file added to toadserver")
}
Esempio n. 3
0
func getFiles(cmd *cobra.Command, args []string) {
	fileName := args[0]

	url := core.UrlHandler(ToadHost, ToadPort, "/getfile?fileName=", fileName)
	resp, err := http.Get(url)
	if err != nil {
		common.IfExit(err)
	}
	defer resp.Body.Close()

	body, err := ioutil.ReadAll(resp.Body)
	if err != nil {
		common.IfExit(err)
	}
	if err := ioutil.WriteFile(fileName, body, 0777); err != nil {
		common.IfExit(err)
	}
}