w3c / FileAPI

File API
https://w3c.github.io/FileAPI/
Other
104 stars 44 forks source link

Add simpler reading methods to Blob interface. #117

Closed mkruisselbrink closed 5 years ago

mkruisselbrink commented 5 years ago

This fixes #40

For now this just more or less copies the hand-wavy text of "perform a read operation". We'll need to better specify what actually reading from a blob does. Separately in a follow-up I would also like to rephrase the existing FileReader/FileReaderSync spec text in terms of readable stream operations, being much more precise when and how state is updated and events are queued.


Preview | Diff

mkruisselbrink commented 5 years ago

@annevk would you mind taking a look at this?

mkruisselbrink commented 5 years ago

(of course this will need tests before landing as well)

mkruisselbrink commented 5 years ago

Okay, rebased this on top of the FileReader changes.

Jamesernator commented 5 years ago

Any possibility of including .dataURL() as well?

annevk commented 5 years ago

@Jamesernator let's track that separately.

mkruisselbrink commented 5 years ago

Tests are in progress in https://chromium-review.googlesource.com/c/chromium/src/+/1526796.

Implementation bugs: Chromium, WebKit, FireFox

jarryd999 commented 5 years ago

Hey @annevk, do you think Mozilla will implement this soon? I'm filing the Intent to Implement/Ship for blink and I'd like to accurately represent Mozilla's stance.

annevk commented 5 years ago

I can't really comment on a timeline, but we're supportive of these methods being added to the web platform.

jimmywarting commented 5 years ago

Any possibility of including .dataURL() as well?

base64 is ~3x larger

jimmywarting commented 5 years ago

Should the FileReader change how it gets the stream?

- Should Let stream be the result of calling get stream on blob .
+ Should Let stream be the result of calling blob.stream()

That would make fileReader a self contained module and it dosen't have to have any internal access to blobs private methods

annevk commented 5 years ago

@jimmywarting please file a new issue if you feel strongly, but generally we don't use that pattern to describe platform objects. If someone were to modify Blob.prototype.stream it shouldn't affect FileReader. It would actually add quite some complexity as we'd have to handle all the exceptional cases that might arise from such a setup.

jimmywarting commented 5 years ago

hmm okey, will stay on the fence. will trust that you know what is best

annevk commented 5 years ago

@jimmywarting happy to discuss this further somewhere somehow. It kinda falls out of IDL and how browsers implement platform objects. https://annevankesteren.nl/2015/01/javascript-web-platform explains some of this, but doesn't really go into why we try to avoid invoking JavaScript once we cross the IDL boundary.