Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to read partial data from the remote files using downloadTo API? #252

Open
aditya81070 opened this issue Apr 24, 2024 · 1 comment
Open

Comments

@aditya81070
Copy link

Describe the bug
This is not a bug but rather a question related to working of download API.

I have already checked #58 and understand how can I use passThrough or writeStreams to download the files or simultaneously. I couldn't find any example for reading partial data from a file.

Example code
A short and standalone code example that demonstrates the issue. Don't copy-paste a few lines from your project, it makes it difficult to rule out issues in other parts of your code.

  const client = new Client();
  await client.access();
  const files = await client.list('/out');
  const readStream = new Stream.PassThrough();
  await client.downloadTo(transform, `/out/${selectedFile.name}`);
 // how to stop the above operation so it doesn't read complete file. 

Console output
Use client.ftp.verbose = true to log every communication detail. Copy-paste the output of your console here. Make sure to redact IPs, URLs or passwords.

Which version of Node.js are you using?
v21.2.0

Which version of basic-ftp are you using?
^5.0.5

Additional context
Add any other context about the problem here. What FTP server are you using? What environment are you running in?

@paulish
Copy link

paulish commented Jan 5, 2025

Yes, need this feature too. I see that I can set the start byte but I see no way to set the end byte as it is possible in fs.createReadStream or s3.GetObject api or mongo GridFS bucket.openDownloadStream api.
I need this feature to properly implement Range http header support for our file service rest api with file/ftp/s3/mongo/... adapters.

I suppose it is possible to somehow wrap destination to stop reading but have not tried yet. At any case it is better to implement in Reader than hacking with Writer.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants