Differences
This shows you the differences between the selected revisions of the page.
library_session_putfile 2021-06-18 | library_session_putfile 2023-12-18 (current) | ||
Line 1: | Line 1: | ||
====== Session.PutFile Method ====== | ====== Session.PutFile Method ====== | ||
- | Uploads data from [[https://docs.microsoft.com/en-us/dotnet/api/system.io.stream|''System.IO.Stream'']] to a remote file. | + | Uploads data from [[https://learn.microsoft.com/en-us/dotnet/api/system.io.stream|''System.IO.Stream'']] to a remote file. |
//For an efficient upload from a physical local file, use [[library_session_putfiletodirectory|''Session.PutFileToDirectory'']] and similar methods instead.// | //For an efficient upload from a physical local file, use [[library_session_putfiletodirectory|''Session.PutFileToDirectory'']] and similar methods instead.// | ||
Line 23: | Line 23: | ||
==== Parameters ==== | ==== Parameters ==== | ||
^ Name ^ Description ^ | ^ Name ^ Description ^ | ||
- | | System.IO.Stream stream | The [[https://docs.microsoft.com/en-us/dotnet/api/system.io.stream|''Stream'']] to upload the data from. The implementation needs to support only the [[https://docs.microsoft.com/en-us/dotnet/api/system.io.stream.read|''Read'' method]]. The stream is read until the ''Read'' method returns zero or throws an exception. The method does not close nor dispose the stream. | | + | | System.IO.Stream ==stream== | The [[https://learn.microsoft.com/en-us/dotnet/api/system.io.stream|''Stream'']] to upload the data from. The implementation needs to support only the [[https://learn.microsoft.com/en-us/dotnet/api/system.io.stream.read|''Read'' method]]. The stream is read until the ''Read'' method returns zero or throws an exception. The method does not close nor dispose the stream. | |
| string ==remoteFilePath== | Full path to a remote file to upload the data to. | | | string ==remoteFilePath== | Full path to a remote file to upload the data to. | | ||
| [[library_transferoptions|TransferOptions]] ==options== | Transfer options. Defaults to ''null'', what is equivalent to ''new TransferOptions()''. | | | [[library_transferoptions|TransferOptions]] ==options== | Transfer options. Defaults to ''null'', what is equivalent to ''new TransferOptions()''. | | ||
- | ===== Remarks ===== | + | ===== [[remarks]] Remarks ===== |
- | Event ''[[library_session_filetransferred|Session.FileTransferred]]'' is raised for the upload. Also raises [[library_session_filetransferprogress|''Session.FileTransferProgress'']] throughout the transfer. | + | Event ''[[library_session_filetransferred|Session.FileTransferred]]'' is raised for the upload. Also raises [[library_session_filetransferprogress|''Session.FileTransferProgress'']] throughout the transfer, but because size of the source data is unknown, the ''FileProgress'' and ''OverallProgress'' fields of [[library_filetransferprogresseventargs|''FileTransferProgressEventArgs'']] are not valid.((The caller of the method can calculate the progress though, by monitoring reads from the stream.)) |
- | Streaming is supported with the [[sftp|SFTP protocol]] only. | + | Streaming is supported with the [[sftp|SFTP]] and [[ftp|FTP]] protocols only. |
+ | |||
+ | Contrary to some other upload methods, like [[library_session_putfiles|''Session.PutFiles'']], this method throws an exception on error automatically. | ||