Post a reply

Options
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)

Options

Topic review

martin

Re: session.PutFile throwing error saying operation not supported

@test12: Please post debug and session logs – Session.SessionLogPath and Sessionm.DebugLogPath.
test12

session.PutFile throwing error saying operation not supported

I am using WinSCP 6.1.1 version but still streaming with FTP isn't working as session.PutFile is throwing error saying "operation not supported".
martin

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.
juhl

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;
FtpSession.ExecutablePath(ExePath);
FtpSession.Open(FtpSessionOptions);
 
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.
martin

Re: Stream File With FTP

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

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? :-)
abesab

Stream File With FTP

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

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

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

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.
nikolasd

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)
        session.Open(sessionOptions);
 
    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?