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)
- Error in DownloadDirectory with progress parameter HOT 3
- Download with Progress throws exception HOT 9
- Download doesn't proceed when deployed to Azure Container HOT 16
- Process hang with GnuTLS on Linux/ARM64 HOT 9
- Upload within Parallel.ForEach() HOT 11
- Expection FluentFTP.Exceptions.FtpCommandException: Code: 550 Message: Command not recognized or allowed when use GetListing method HOT 2
- AuthenticateAsClientAsync doesn't respect ReadTimeout in a certain scenario HOT 4
- FtpException thrown downloading file with 49.0.2 works in 49.0.1 HOT 4
- Problems uploading a file into a ftp server with TLS HOT 7
- AsyncFtpClient - The operation has timed out HOT 29
- PRT and EPRT don't respect the configured proxy HOT 6
- GetObjectInfo fails for file names with spaces HOT 6
- Error on FTP UPDATFILE after sucessfull connect HOT 1
- Override Read(Span), ReadAsync(Memory), Write(ROS), WriteAsync(ROM) in streams HOT 3
- Issue with AS400 change - AfterConnect actions cannot be undone HOT 22
- Should FTP work be done with temp files? HOT 5
- GetListing Chinese garbled characters HOT 3
- Timeouts when downloading certain files HOT 2
- ftp.GetListing(path) HOT 1
- using the GetListing Error HOT 2
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.