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

res.sendFile support for encrypted files #3193

Closed
ediweissmann opened this issue Feb 1, 2017 · 4 comments
Closed

res.sendFile support for encrypted files #3193

ediweissmann opened this issue Feb 1, 2017 · 4 comments
Assignees
Labels

Comments

@ediweissmann
Copy link

I'd like to be able to serve encrypted files with res.sendFile().
Maybe by passing a decrypting stream via opts, that is piped along with the file contents?

Thanks.

@dougwilson
Copy link
Contributor

Hi! Would you be willing to flesh out the proposal a bit more so we can understand what would need to be implemented to support your use-case? You're also definitely welcome to start up a PR even if it's incomplete if that is a more preferred way to start on a proposal (code vs words) :)

@ediweissmann
Copy link
Author

Hi,

Use-case is:

  • files are stored encrypted on disk.
  • I'd like to use res.sendFile() and pass a transforming stream, that decrypts the files.
var decrypt = crypto.createCipher(algorithm, password);
var opts = {
  transform: function(stream) { 
    return stream.pipe(decrypt);
  }
}
res.sendFile(path, opts, cb);

I've tried implementing this in an Express PR.
Realised Express uses pillarjs/send for the file streaming.
So, support for transforming streams would first need to land in pillarjs/send.
Noticed one open PR exists on the subject.
Options already are passed through, so no change required in Express.

@dougwilson
Copy link
Contributor

Ah, good catch on that send PR. I added a comment for an issue it has, which I believe would be an issue if you are trying to decrypt files as well.

@dougwilson dougwilson self-assigned this Feb 2, 2017
@ediweissmann
Copy link
Author

Thanks, your comment was very helpful.

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

No branches or pull requests

2 participants