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

REQ: Obtain a PUT write stream #13

Open
ghost opened this issue Apr 21, 2019 · 0 comments
Open

REQ: Obtain a PUT write stream #13

ghost opened this issue Apr 21, 2019 · 0 comments

Comments

@ghost
Copy link

ghost commented Apr 21, 2019

Hi and thanks for updating this project.

Would it be feasible to expose a PUT write stream (or its socket) in a clean way?

Much like get() which provides a read stream, but with put() we can only set a file name. It would be very nice to have something like putStream() which we then can write arbitrarily to.

You could do interesting things with one, such as for instance piping different source files into a single ZIP archive on the FTP server.:

// see: https://github.com/archiverjs/node-archiver
var archive = archiver('zip', { zlib: { level: 9 }});

// .. connect to FTP server and obtain a FTP write stream:
var ftpWriteStream = ftpClient.putStream('filename.zip'):

archive.pipe(ftpWriteStream);  // here!

archive.append(someReadStream1, { name: 'file1.txt' });
archive.append(someReadStream2, { name: 'file2.txt' });
archive.append(someReadStream3, { name: 'file2.txt' });
archive.finalize();

//...
// Done, and one single file created directly on the FTP server
// with no need for temp on local.

Pseudo implementation:

client.putStream = function(file, callback) {
  issue STOR cmd + checks on command socket
  if OK callback with data socket
}
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

0 participants