Comments (8)
It may cause edge cases in your testing, but it's limiting. How? When you are passing Stream as parameter to write file to server, you have to know content of the file in the moment you are calling the method. This makes things like fly-by-copy impossible. You would have to download entire file to memory and then send it to the second server. If Stream was returned, instead of passing it a parameter, you could send the file regardles if you know the content beforehand or not.
As for reading files from server, there are cases like this too. One of them: you want to seek in the file and read only a part of it. With returned Stream it's easy. With Stream as parameter, you have to download entire file to disk (too large to hold in RAM) and then do the seek. This is very inefficient.
Those cases can be handled, but with some very cumbersome and hacky Stream implementations. No need to do this with returned Streams versions.
Here is another example. Consider two methods in some API that have the following signatures:
Stream OpenStream(string path, FileAccess access);
void OpenStream(Stream targetStream, string path, FileAccess access);
There is no way to use FluentFTP's methods DownloadFile and UploadFile to implement the first method.
However, if FluentFTP's methods were OpenRead and OpenWrite both of given methods could be implemented easly.
from fluentftp.
Good points. I'll consider removing the Obsolete attribute.
from fluentftp.
I've removed the Obsolete attribute from those methods. I added the attribute because I wanted older/existing users to know that DownloadFile and UploadFile methods are there and should be used in most cases. They have extra code like : reading the FtpReply at the end of the transfer to prevent "stale data" on the socket. This code will have to be manually added by the user.
from fluentftp.
Can you expand on reading the FtpReply? I'm using OpenRead and OpenWrite in a project, and want to make sure I have all the edge cases covered.
from fluentftp.
Awesome. I appreciate the help, and the work you've done on this library, Harsh.
from fluentftp.
DownloadFile and UploadFile also have stream versions. Does that work for you? You can upload any stream and download will return a MemoryStream.
OpenRead and OpenWrite cause many edge cases in my testing. It must be carefully closed, extra commansd, etc.
from fluentftp.
Basically after successfully transferring a file, the server sends back a message to indicate if the transfer was successful/failed. To read this just call GetReply like this. If you don't read this message, the next time you send a command it crashes with "stale data on socket".
Use the code in UploadFileInternal/DownloadFileInternal for reference. Also I found reading the file in chunks is a good idea, so perhaps you want to take the mentioned functions are fork them for your usage rather than starting from scratch.
from fluentftp.
@julian-goldsmith - Thank you! Its very kind of you...
from fluentftp.
Related Issues (20)
- Multi-File operations should provide a overall progress HOT 13
- How often do you update NuGet? HOT 2
- Release page and release tags are missing HOT 1
- Request for Nuget 49.0.2 HOT 4
- Question about 'DownloadDirectory()' HOT 1
- Error using clone function with async client HOT 5
- Disposing a connected AsyncFtpClient throws non-fatal System.InvalidCastException in version 49.0.* HOT 42
- System.InvalidCastException exception Thrown After File Upload Completes HOT 1
- Reuse Connection? HOT 3
- Error 550 file not found HOT 1
- ACTIVE mode FTP is raising Exception of Timeout but working in FileZilla and WinSCP HOT 7
- Resume Progress Problem
- timeout exception after download and upload all bytes HOT 8
- GetListing during DownloadFile/UploadFile async error HOT 4
- The AsyncFtpClientSocks5Proxy.cs need Add code HOT 2
- Connection lost between server and client not handled. HOT 12
- MLSD Last Modified DateTime.Kind HOT 2
- FtpCommandException: Code: 553 Message: Could not create file.
- Enhancement: Extend the built-in verification of all major file transfer methods with size comparison. HOT 5
- Support handling retries on Authentication Exceptions HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from fluentftp.