Our Products:   CompleteFTP  edtFTPnet/Free  edtFTPnet/PRO  edtFTPj/Free  edtFTPj/PRO
0 votes
15 views
ago in .NET FTP by (800 points)
I'm using edtFTPNetPro version 12.3.  While using the SecureFTPConnection with the SCP protocol, a call to UploadStream raises a NotSupportedException.  It seemed to work with FTP and I haven't tried SFTP.  Is this just a limitation of the library with SCP?  Is it supported in a newer version?

1 Answer

0 votes
ago by (9.6k points)
edited ago by
It's a limitation in the SCP protocol because it requires the file size to be sent before the data. So it can't be properly implemented. If you really need it, use SFTP.

Another alternative is to read your stream into a byte array first and use UploadByteArray.
ago by (800 points)
I have 2 other libraries that my users can switch between depending on preference or performance.  They both have a function to upload from a stream that works just fine with SCP, so I'm not sure how they're getting around the file size issue.  SFTP is not an option because the devices I'm uploading to only support SCP.

I've considered the UploadByteArray option.  My only concern there is running into memory issues if the amount of data being uploaded is large, which is potentially the case.  I've also considered just saving the stream to a temporary file, uploading it, and then deleting the temporary file.  But the data I'm uploading is being decrypted from a secure source and I'd rather not have the unencrypted version sitting around in a file, even it's just temporary.

I might just have to force the program to use one of my other libraries in this particular instance.
ago by (9.6k points)
SCP is not a single protocol. There's the original scp protocol, and then there's scp over the SFTP subsystem (scp -s), which is what OpenSSH has moved to by default and which essentially runs the SFTP transfer engine underneath. A library that "just works" with streams over SCP is almost certainly either using the subsystem form, or buffering internally and sending a size it learned only after the fact. The classic protocol can be streamed too, with one trick: send a size first and, if the byte count turns out different, the sender and receiver cope with it (or the library simply buffers to get the length). So the file-size field is a real wrinkle, not an absolute barrier — which means NotSupportedException from UploadStream in your version is a library implementation choice for the SCP code path.
A third option, if the SCP path in your version simply can't stream and the data size is unbounded: use one of the two libraries that already streams correctly for this transfer, and keep edtFTPnet/PRO for the FTP paths it does handle. You've already got them integrated behind a switch, so the cost is low — and it avoids holding plaintext on disk, which is the one constraint here that I'd treat as non-negotiable.

If you can paste the exact NotSupportedException message and redacted stack trace, it will show whether the throw sits in the SCP command/transfer code or in a shared stream layer, which is the difference between "this protocol path was never implemented" and "this particular overload is blocked."
ago by (800 points)
Stack trace is:

System.NotSupportedException: This operation is not currently supported.
   at EnterpriseDT.Net.Ftp.Ssh.SSHSCPClient.Put(Stream input, String remote, Boolean append)
   at EnterpriseDT.Net.Ftp.FTPConnection.UploadStream(Stream srcStream, String remoteFile, WriteMode writeMode)
   at EnterpriseDT.Net.Ftp.ExFTPConnection.UploadStream(Stream srcStream, String remoteFile, Boolean append)
   at EnterpriseDT.Net.Ftp.ExFTPConnection.UploadStream(Stream srcStream, String remoteFile)
   at VoipShell.EdtFileClient.SendStreamToFile(Stream SourceStream, String RemoteFile)


FYI, I also attempted it with the 12.8 trial version and had the same exception.

Categories

...