Crypter-File-Transfer / Crypter

A Blazor WASM web application that offers end-to-end encrypted file and message transfer using Libsodium, Entity Framework, Hangfire, Docker, NUnit, and Mailkit.
https://www.crypter.dev
GNU Affero General Public License v3.0
36 stars 15 forks source link

[Feature] Investigate streamed downloads #576

Closed Jack-Edwards closed 1 month ago

Jack-Edwards commented 1 year ago

Description

The primary reason for limiting file transfers to 100 MB is to accommodate mobile browsers. The majority of mobile browsers are still 32-bit, meaning they are limited to 2 GB of memory.

Currently, the sequence of events for downloading an encrypted file goes:

  1. Download the full ciphertext into memory.
  2. Decrypt the file ciphertext to plaintext, in memory.
  3. Copy the entire plaintext to the page as a base64 blob.
  4. Download the blog to the device.

A 100 MB file may actually have a 300 MB memory footprint. The last thing I want is for an OutOfMemoryException to occur during file downloads.

Now consider this answer from SO: https://stackoverflow.com/a/39685380

and this repository: https://github.com/jimmywarting/StreamSaver.js

It should be possible to perform streaming downloads. Which means a much smaller memory footprint during download; potentially up to an arbitrary chunk size. Which means I could drastically increase the file transfer size limit.

Jack-Edwards commented 1 year ago

I intend to create a NuGet package for this issue. If anyone else gets to it first, please drop a link here!

Edit: I may not be working on this after all. Time constraints.

Jack-Edwards commented 1 year ago

Proton also has a good implementation. They add an Iframe to the page, instead of depending on a separate, static site to host the service worker.

https://github.com/ProtonMail/WebClients/blob/main/applications/drive/src/app/store/_downloads/fileSaver/fileSaver.ts

Jack-Edwards commented 11 months ago

https://github.com/Jack-Edwards/BlazorStreamSaver/tree/add-blazor-binding

Jack-Edwards commented 5 months ago

Proof of concept is working on this branch: https://github.com/Crypter-File-Transfer/Crypter/tree/feature/streamed-downloads

Remaining work:

Jack-Edwards commented 5 months ago

715

Jack-Edwards commented 4 months ago

Blocked by #717

Jack-Edwards commented 1 month ago

Resolved! These changes are currently in the stable branch.