Hello everyone,
First time poster here so if anything doesn’t make sense, please let me know and I’d be happy to explain 🙂
I’m currently working on a Node.js application where I need to handle file uploads using tus-node-server. The frontend is using the Uppy TUS plugin. I need to be able to encrypt the files as they are uploaded and then upload the encrypted files directly to an S3 bucket.
Due to limited storage space, I can’t afford to store the files temporarily on disk. Instead, I want to process and encrypt the files as they are being uploaded and stream the encrypted content directly to S3. I’ve also opted against using Server-Side Encryption on its own in S3, as if someone gained unauthorized access to my S3 bucket, they could just download the files unencrypted.
I understand there is no native way of doing this in @tus/server and @tus/s3-store, which is fine, as I have my own encryption logic using crypto.
I have managed to successfully get everything working so that the client can upload files using TUS to my S3 bucket with both modules mentioned above.
I just need a way of pre-processing each chunk before it is sent to S3. My main question is this:
Is there any way to extract/retrieve/intercept the uploaded chunk so that I can perform my encryption logic, and then pass it back to the TUS server/S3 Datastore?
Any help, suggestions, or examples would be greatly appreciated!
Thank you!