Skip to content

SFTP WriteAllBytes Corrupt #218

@rrs

Description

@rrs

Hi,

I am uploading a csv file to sftp. The file ends up corrupted.
After ~250 lines it reprints the column headers along with the first ~250 rows instead of the following ~250 rows then continues on with the rest of the file.

I have the same application deployed to multiple locations and only some locations exhibit this behavior. I log the output locally and can verify the output itself is correct.

Here is the upload code

var fileBytes = Encoding.UTF8.GetBytes(file);
var connectionInfo = new ConnectionInfo(_settings.FtpServer, _settings.FtpUserName, new PasswordAuthenticationMethod(_settings.FtpUserName, _settings.FtpPassword));
using (var client = new SftpClient(connectionInfo))
{
    client.Connect();
    client.WriteAllBytes($"{_settings.FtpPath}/{fileName}", fileBytes);
    CsvLogger.Info(file);
}

I have also tried using client.OpenWrite and .Write instead and still the same issue.

Any advice would be appreciated

Thanks

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions