code: func (c *Communicator) Upload(path string, input io.Reader) error {
  	// The target directory and file for talking the SCP protocol
  	targetDir := filepath.Dir(path)
  	targetFile := filepath.Base(path)
  
  	// On windows, filepath.Dir uses backslash separators (ie. "\tmp").
  	// This does not work when the target host is unix.  Switch to forward slash
  	// which works for unix and windows
  	targetDir = filepath.ToSlash(targetDir)
  
  	// Skip copying if we can get the file size directly from common io.Readers
  	size := int64(0)
  
  	switch src := input.(type) {
  	case *os.File:
  		fi, err := src.Stat()
  		if err != nil {
  			size = fi.Size()
  		}
  	case *bytes.Buffer:
  		size = int64(src.Len())
  	case *bytes.Reader:
  		size = int64(src.Len())
  	case *strings.Reader:
  		size = int64(src.Len())
  	}
  
  	scpFunc := func(w io.Writer, stdoutR *bufio.Reader) error {
  		return scpUploadFile(targetFile, input, w, stdoutR, size)
  	}
  
  	return c.scpSession("scp -vt "+targetDir, scpFunc)
  }
docs: // Upload implementation of communicator.Communicator interface