Post a reply

Add an Attachment

If you do not want to add an Attachment to your Post, please leave the Fields blank.

(maximum 10 MB; please compress large files; only common media, archive, text and programming file formats are allowed)


Topic review


Re: Stream File With FTP

Your code makes no sense. First, the Session.GetFile does not return MemoryStream. It returns a custom implementation of the Stream interface. And it indeed does not implement a writable Position property.
Second, the returned stream is at the beginning. There's no need to seek it.

Re: Stream File With FTP

Hi Martin

Code: (not C# syntax but .NET code)
FtpSessionOptions := FtpSessionOptions.SessionOptions;
FtpSessionOptions.Protocol := FtpProtocol.Ftp;
FtpSessionOptions.HostName := Host;
FtpSessionOptions.UserName := Username;
FtpSessionOptions.Password := Password;
FtpSessionOptions.FtpSecure := FtpSecure.Explicit;
FtpSessionOptions.GiveUpSecurityAndAcceptAnyTlsHostCertificate := TRUE;
FtpSession := FtpSession.Session;
MemoryStream := FtpSession.GetFile(Path, FtpTransferOptions);
MemoryStream.Position := 0; // Gives the error

Error is:

WinSCP.PipeStream.Position failed: Specified method is not supported.

I need to seek back to get the file data from MemoryStream.

Re: Stream File With FTP

@juhl: Please show us your code and complete exception stack trace.

Re: Stream File With FTP

Hi Martin

I'm trying out the new stream method, and the GetFile seems to work.
But to get the content of the Stream (I use MemoryStream), I do a Position = 0, to get to the start of the stream, but this operation is not supported.

Any good ideas? :-)

Stream File With FTP

Is there any way to upload a stream with FTP without saving it first to a temporary file?

Re: Using Session.PutFile() with stream, returns error Operation not supported

Unfortunately, I am using FTPS. Thank you for clarifying it.

Re: Using Session.PutFile() with stream, returns error Operation not supported

What protocol are you using? The streaming is supported with the SFTP protocol only. With other protocols, you need to save the data to (temporary) file before uploading.

Using Session.PutFile() with stream, returns error Operation not supported

I am using the latest RC release of WinSCP NuGet package and I am trying to implement PutFile
using (var session = new Session()) {
    if (!session.Opened)
    var transferOptions = new TransferOptions {
        TransferMode = TransferMode.Binary,
        OverwriteMode = OverwriteMode.Overwrite,   
    using (var stream = new MemoryStream(imgData)) {
        session.PutFile(stream, remoteFilePath, transferOptions);

session.PutFile throws exception with error message
Operation not supported.

What can be the issue that is causing this error?