I have a client-side JS aapplication where I want to use Web Streams to process some input file from the user. The file could either be a text file (in which case I just pipe it through a TextDecoderStream and then do whatever I want with it) or a gzipped text file (in which case I need to pipe it through a DecompressionStream before it gets to the TextDecoderStream).
What’s the best way to handle this?
I could make the user manually click a checkbox for compressed or not, but that’s poor UI.
I could look at the filename of the uploaded file, but that may not always be accurate.
I guess ideally I’d write some DecompressionStreamIfNecessary transform stream that I could just pipe through and it would decompress the stream if necessary or do nothing otherwise. idk if that’s possible though.
What’s the best way to do this?