Uploading a File from a Stream Using the FTP Component
FTP components allow files to be uploaded directly from memory or file streams instead of relying only on physical file paths. This is useful for processing dynamic data or large files efficiently.
As of IPWorks V8, the FTP component supports uploading data directly from a stream to a remote file. The stream must be open and typically positioned at the beginning (position 0). By default, the component will automatically close the stream after transfer unless CloseStreamAfterTransfer is set to false.
C#
ftp.RemoteFile = "test.txt";
ftp.SetUploadStream(new FileStream("c:\\test.txt", FileMode.Open));
ftp.Upload();
VB.NET
ftp.RemoteFile = "test.txt"
ftp.SetUploadStream(New FileStream("c:\\test.txt", FileMode.Open))
ftp.Upload()
Java
ftp.setRemoteFile("test.txt");
ftp.setUploadStream(new java.io.FileInputStream("c:\\test.txt"));
ftp.upload();
We appreciate your feedback. If you have any questions, comments, or suggestions about this article please contact our support team at support@nsoftware.com.