No error returned for upload but no file for SFTP

func (c *Client) Upload(local, remote string) error {
    client, err := sftp.NewClient(c.SSHClient)
    if err != nil {
        return err
    }
    defer client.Close()

    localFile, err := os.Open(local)
    if err != nil {
        return err
    }
    defer localFile.Close()

    remoteFile, err := client.Create(remote)
    if err != nil {
        return err
    }

    _, err = io.Copy(remoteFile, localFile)
    return err
}

I call this function to upload a file to SFTP, and no error is returned.

upload using the command line as follows:

I use the above function to upload:

var localFilePath = "./1234.zip"
var remoteDir = "upload/uuuuu.zip"
err = client.Upload(localFilePath, remoteDir)
if err != nil {
    panic(err)
}
fmt.Println("")

No errors are returned in the execution result, only
This service allows sftp connections only.

is returned.

but log in to SFTP, there are no uploaded files, please give us some advice!

Mar.11,2021

has the subject solved the same question

Menu