W3C home > Mailing lists > Public > public-webapps@w3.org > July to September 2013

Re: Overlap between StreamReader and FileReader

From: Takeshi Yoshino <tyoshino@google.com>
Date: Thu, 26 Sep 2013 23:45:04 +0900
Message-ID: <CAH9hSJa=irdK6r6RW2t0xTtRUPKPpw_pn+HcARLH4mC2ZuTRWg@mail.gmail.com>
To: Aymeric Vitte <vitteaymeric@gmail.com>
Cc: Isaac Schlueter <i@izs.me>, Jonas Sicking <jonas@sicking.cc>, Austin William Wright <aaa@bzfx.net>, Domenic Denicola <domenic@domenicdenicola.com>, "public-webapps@w3.org" <public-webapps@w3.org>
On Thu, Sep 26, 2013 at 6:36 PM, Aymeric Vitte <vitteaymeric@gmail.com>wrote:

> Looks good, comments/questions :
>
> - what's the use of readEncoding?
>

Overriding charset specified in .type for read op. It's weird but we can
ask an app to overwrite .type instead.


>
> - StreamReadType: add MediaStream? (and others if existing)
>

Maybe, if there's clear rule to convert binary stream + MIME type into
MediaStream object.


>
> - would it be possible to pipe from StreamReadType to other StreamReadType?
>

pipe() tells the receiver with which value of StreamReadType the pipe() was
called. Receiver APIs may be designed to accept either mode or both modes.


>
> - would it be possible to pipe from a source to different targets (my
> example of encrypt/hash at the same time)?
>

I missed it. Your mirroring method (making pipe accept multiple Stream)
looks good.

The problem is what to do when one of destinations is write blocked. Maybe
we want to read data from the source as the fastest consumer consumes and
save read data for slowest one. When should we fulfill the promise?
Completion of read from the source, completion of write to all
destinations, etc.


>
> - what is the link between the API and the Stream (responseType='stream')?
> How do you handle this for APIs where responseType does not really apply
> (mspack, crypto...)
>

- make APIs to return a Stream for read (write) like
XHR.responseType='stream'
- make APIs to accept a Stream for read (write)

Either should work as we have pipe().

E.g.

var sourceStream = xhr.response;
var resultStream = new Stream();
var fileWritingPromise = fileWriter.write(resultStream);
var encryptionPromise = crypto.subtle.encrypt(aesAlgorithmEncrypt, aesKey,
sourceStream, resultStream);
Promise.all(fileWritingPromise, encryptionPromise).then(
  ...
);

----

I also found a point needs clarification

- pipe() does eof or not. I think we don't want automatic eof.
Received on Thursday, 26 September 2013 14:45:56 UTC

This archive was generated by hypermail 2.4.0 : Friday, 17 January 2020 18:14:13 UTC