Skip to content

REQ: Obtain a PUT write stream #13

Open
@ghost

Description

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
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions