// Create a file to the session
Create a file to the session
// Create a file to the session
func (s session) CreateFile(path, name string, data []byte) error {
	file, err := ioutil.TempFile(".", name)
	if err != nil {
		return err
	}
	defer os.Remove(file.Name())
	if err := file.Close(); err != nil {
		return err
	}
	if err := ioutil.WriteFile(file.Name(), data, 0644); err != nil {
		return err
	}
	wd, err := os.Getwd()
	if err != nil {
		return err
	}
	return s.CopyItemFromHost(fmt.Sprintf("%s\\%s", wd, file.Name()), fmt.Sprintf("%s\\%s", path, name))
}
func ( s session ) CreateFile ( path , name string , data [ ] byte ) error { file , err := ioutil . TempFile ( " " , name ) if err != nil { return err } defer os . Remove ( file . Name ( ) ) if err := file . Close ( ) ; err != nil { return err } if err := ioutil . WriteFile ( file . Name ( ) , data , 0644 ) ; err != nil { return err } wd , err := os . Getwd ( ) if err != nil { return err } return s . CopyItemFromHost ( fmt . Sprintf ( " \\ " , wd , file . Name ( ) ) , fmt . Sprintf ( " \\ " , path , name ) ) }
Create a file to the session
Create a file to the session