Table of Contents

Class SftpTransferOptions

Namespace
SshSharp.Sftp
Assembly
SshSharp.dll

Options for SftpClient's uploads and downloads.

public sealed class SftpTransferOptions
Inheritance
SftpTransferOptions
Inherited Members

Properties

MaxRequestsInFlight

How many reads or writes may be in flight at once (default 64, as OpenSSH's sftp). More helps on links with latency.

Overwrite

Replace an existing destination file (default true, as sftp put and get do); otherwise it is an error.

Preserve

Copy the source's modification and access times, and its permission bits (read, write and execute for the owner, the group and others), to the destination, as sftp -p does. Permissions are copied only where the receiving side has Unix modes: a download to Windows keeps the times only, and an upload from Windows sends none. Unlike OpenSSH, setuid, setgid and the sticky bit are never copied, so a server cannot hand this machine a setuid file.

Progress

Reports each file's progress: its path, the bytes transferred so far and its size, when known.

Resume

Continue an interrupted transfer, as sftp's reget and reput do: the destination's existing bytes are taken as the source's first ones, and only the rest is sent; a destination larger than the source is an error. Nothing checks that the existing bytes match, so use it for the same file only. A failed download with this set keeps what arrived. Overrides Overwrite for an existing destination.

Segments

How many parts of one file DownloadFileAsync(string, string, SftpTransferOptions?, CancellationToken) fetches at once, each over its own SFTP session on the same connection (default 1: one session). Each session is an SSH channel with its own flow-control window, and on OpenSSH its own sftp-server process, so on a link with high latency several segments move more than one session can: one session carries at most its 2 MiB window per round trip. It does not help where the bandwidth, or the server's single connection, is the limit. Files smaller than 1 MiB per segment use fewer segments; the server may allow fewer sessions (sshd's MaxSessions, 10 by default), and then fewer are used. Ignored with Resume (only a sequential download leaves a prefix to resume from) and by DownloadAsync(string, Stream, SftpTransferOptions?, CancellationToken), which writes a stream in order. Each extra session opens the file by path, so a file whose size or modification time has changed by then (replaced, or still being written) fails the download.