'Compress/encrypt/upload and download/decrypt/decompress a file in C#

I searched the internet and here but found nothing useful. I hope someone can give me some advice.

I need to compress-encrypt-upload a (very) large file to a server and go back (ie: download-decrypt-decompress). The specifics of the project say that:

  • I shouldn't save any data on the local hard drive
  • I should use as little memory as possible

The idea I got is that of concatenating a series of streams in order to read from a file and send the result directly to the server:

  • GZipStream / Brotli to compress the file
  • CryptoStream to encrypt the compressed file
  • HttoClient to upload

Does anyone have any suggestions/solutions/links?

Thanks so much.



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source