Tal Sofer
10/26/2021, 6:49 AMapplication/octet-stream
, and I’m looking into using a react library that can calculate the diff for me, this library gets file contents as strings.
• Should I first read the contents and save it in-memory and then compare it?
• What is the right way to read from a stream in javascript?
@Barak Amar @Ariel Shaqed (Scolnicov) do you have useful tips to share?Itai Admi
10/26/2021, 7:02 AMTal Sofer
10/26/2021, 7:05 AMBarak Amar
Ariel Shaqed (Scolnicov)
10/26/2021, 8:26 AMdiff
should work for streaming input, or at most seekable streaming input. E.g. diff
has a --speed-large-files
option that might help here.
3. Please separate detecting file type from file diff. File type should ideally come from the Content-Type
header rather than a heuristic. And if we separate, we can switch the one without switching the other. Since users are very likely to have an opinion about the desired behaviour, we should make our lives easier to support the right one on each side.
4. You need to figure out how to read from a network connection in JavaScript. You will need to use XMLHttpRequest ("XHR") or the newer Fetch (see the page on MDN for basic expectations of browser support for this). Fetch returns this kind of Response object, you could probably ask for fewer bytes than the whole thing and then use Response.blob if you need everything in memory.