Giter VIP home page Giter VIP logo

Comments (8)

dex3r avatar dex3r commented on May 21, 2024 1

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.

robinrodricks avatar robinrodricks commented on May 21, 2024 1

Good points. I'll consider removing the Obsolete attribute.

from fluentftp.

robinrodricks avatar robinrodricks commented on May 21, 2024 1

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.

julian-goldsmith avatar julian-goldsmith commented on May 21, 2024 1

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.

julian-goldsmith avatar julian-goldsmith commented on May 21, 2024 1

Awesome. I appreciate the help, and the work you've done on this library, Harsh.

from fluentftp.

robinrodricks avatar robinrodricks commented on May 21, 2024

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.

robinrodricks avatar robinrodricks commented on May 21, 2024

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.

robinrodricks avatar robinrodricks commented on May 21, 2024

@julian-goldsmith - Thank you! Its very kind of you...

from fluentftp.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.