-
Notifications
You must be signed in to change notification settings - Fork 162
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Added FileReaderSync to dom.experimental #424
Conversation
The usecase of this code is something like this: let image that user is making a protonmail or any another application where content inside frontend (=browser storage) some secret user's data that shouldn't be exposed to backend. Secret key for example or anything like that. This code allows to developer to convert any `Array[Byte]` from frontend to URL as simple call `FileService.asURL`, create an anchor to download it as `FileService.asAnchor` and asynchronously convert any uploaded `File` to `Array[Byte]` as `FileService.asBytesArray`, or to `InputStream` via `FileService.asInputStream`. Unfortunately scalatags doesn't support `download` attribute and I need to make it by hand. I've opened a PR: com-lihaoyi/scalatags#212 to introduce it, but it might be a while until it is included to release. `FileService.asInputStream` is using `FileReaderSync` that is also missed inside scala-js-dom. I've opened a PR: scala-js/scala-js-dom#424 but it might be a while. Also, this is draft API but it is supported by majority of modern browsers: https://developer.mozilla.org/en-US/docs/Web/API/FileReaderSync#Browser_Compatibility
69f46d5
to
23c4c43
Compare
The usecase of this code is something like this: let image that user is making a protonmail or any another application where content inside frontend (=browser storage) some secret user's data that shouldn't be exposed to backend. Secret key for example or anything like that. This code allows to developer to convert any `Seq[Array[Byte]]` from frontend to URL as simple call `FileService.asURL`, create an anchor to download it as `FileService.asAnchor` and asynchronously convert any uploaded `File` to `Array[Byte]` as `FileService.asBytesArray`, or to `InputStream` via `FileService.asInputStream`. Unfortunately scalatags doesn't support `download` attribute and I need to make it by hand. I've opened a PR: com-lihaoyi/scalatags#212 to introduce it, but it might be a while until it is included to release. `FileService.asInputStream` is using `FileReaderSync` that is also missed inside scala-js-dom. I've opened a PR: scala-js/scala-js-dom#424 but it might be a while. Also, this is draft API but it is supported by majority of modern browsers: https://developer.mozilla.org/en-US/docs/Web/API/FileReaderSync#Browser_Compatibility
The usecase of this code is something like this: let image that user is making a protonmail or any another application where content inside frontend (=browser storage) some secret user's data that shouldn't be exposed to backend. Secret key for example or anything like that. This code allows to developer to convert any `Seq[Array[Byte]]` from frontend to URL as simple call `FileService.asURL`, create an anchor to download it as `FileService.asAnchor` and asynchronously convert any uploaded `File` to `Array[Byte]` as `FileService.asBytesArray`, or to `InputStream` via `FileService.asInputStream`. Unfortunately scalatags doesn't support `download` attribute and I need to make it by hand. I've opened a PR: com-lihaoyi/scalatags#212 to introduce it, but it might be a while until it is included to release. `FileService.asInputStream` is using `FileReaderSync` that is also missed inside scala-js-dom. I've opened a PR: scala-js/scala-js-dom#424 but it might be a while. Also, this is draft API but it is supported by majority of modern browsers: https://developer.mozilla.org/en-US/docs/Web/API/FileReaderSync#Browser_Compatibility
The usecase of this code is something like this: let image that user is making a protonmail or any another application where content inside frontend (=browser storage) some secret user's data that shouldn't be exposed to backend. Secret key for example or anything like that. This code allows to developer to convert any `Seq[Array[Byte]]` from frontend to URL as simple call `FileService.asURL`, create an anchor to download it as `FileService.asAnchor` and asynchronously convert any uploaded `File` to `Array[Byte]` as `FileService.asBytesArray`, or to `InputStream` via `FileService.asInputStream`. Unfortunately scalatags doesn't support `download` attribute and I need to make it by hand. I've opened a PR: com-lihaoyi/scalatags#212 to introduce it, but it might be a while until it is included to release. `FileService.asInputStream` is using `FileReaderSync` that is also missed inside scala-js-dom. I've opened a PR: scala-js/scala-js-dom#424 but it might be a while. Also, this is draft API but it is supported by majority of modern browsers: https://developer.mozilla.org/en-US/docs/Web/API/FileReaderSync#Browser_Compatibility
The usecase of this code is something like this: let image that user is making a protonmail or any another application where content inside frontend (=browser storage) some secret user's data that shouldn't be exposed to backend. Secret key for example or anything like that. This code allows to developer to convert any `Seq[Array[Byte]]` from frontend to URL as simple call `FileService.createURL`, asynchronously convert any uploaded `File` to `Array[Byte]` as `FileService.asBytesArray`, or to `InputStream` via `FileService.asInputStream` inside worker. Unfortunately scalatags doesn't support `download` attribute and I need to make it by hand. I've opened a PR[^1] to introduce it, but it might be a while until it is included to release. `FileService.asInputStream` is using `FileReaderSync` that is also missed inside scala-js-dom. I've opened a PR[^2] but it might be a while. Also, this draft API but it is supported by majority of modern browsers[^3]. [^1]: com-lihaoyi/scalatags#212 [^2]: scala-js/scala-js-dom#424 [^3]: https://caniuse.com/?search=FileReaderSync
The usecase of this code is something like this: let image that user is making a protonmail or any another application where content inside frontend (=browser storage) some secret user's data that shouldn't be exposed to backend. Secret key for example or anything like that. This code allows to developer to convert any `Seq[Array[Byte]]` from frontend to URL as simple call `FileService.createURL`, asynchronously convert any uploaded `File` to `Array[Byte]` as `FileService.asBytesArray`, or to `InputStream` via `FileService.asInputStream` inside worker. Unfortunately scalatags doesn't support `download` attribute and I need to make it by hand. I've opened a PR[^1] to introduce it, but it might be a while until it is included to release. `FileService.asInputStream` is using `FileReaderSync` that is also missed inside scala-js-dom. I've opened a PR[^2] but it might be a while. Also, this draft API but it is supported by majority of modern browsers[^3]. [^1]: com-lihaoyi/scalatags#212 [^2]: scala-js/scala-js-dom#424 [^3]: https://caniuse.com/?search=FileReaderSync
The usecase of this code is something like this: let image that user is making a protonmail or any another application where content inside frontend (=browser storage) some secret user's data that shouldn't be exposed to backend. Secret key for example or anything like that. This code allows to developer to convert any `Seq[Array[Byte]]` from frontend to URL as simple call `FileService.createURL`, asynchronously convert any uploaded `File` to `Array[Byte]` as `FileService.asBytesArray`, or to `InputStream` via `FileService.asInputStream` inside worker. Unfortunately scalatags doesn't support `download` attribute and I need to make it by hand. I've opened a PR[^1] to introduce it, but it might be a while until it is included to release. `FileService.asInputStream` is using `FileReaderSync` that is also missed inside scala-js-dom. I've opened a PR[^2] but it might be a while. Also, this draft API but it is supported by majority of modern browsers[^3]. [^1]: com-lihaoyi/scalatags#212 [^2]: scala-js/scala-js-dom#424 [^3]: https://caniuse.com/?search=FileReaderSync
The usecase of this code is something like this: let image that user is making a protonmail or any another application where content inside frontend (=browser storage) some secret user's data that shouldn't be exposed to backend. Secret key for example or anything like that. This code allows to developer to convert any `Seq[Array[Byte]]` from frontend to URL as simple call `FileService.createURL`, asynchronously convert any uploaded `File` to `Array[Byte]` as `FileService.asBytesArray`, or to `InputStream` via `FileService.asInputStream` inside worker. Unfortunately scalatags doesn't support `download` attribute and I need to make it by hand. I've opened a PR[^1] to introduce it, but it might be a while until it is included to release. `FileService.asInputStream` is using `FileReaderSync` that is also missed inside scala-js-dom. I've opened a PR[^2] but it might be a while. Also, this draft API but it is supported by majority of modern browsers[^3]. [^1]: com-lihaoyi/scalatags#212 [^2]: scala-js/scala-js-dom#424 [^3]: https://caniuse.com/?search=FileReaderSync
The usecase of this code is something like this: let image that user is making a protonmail or any another application where content inside frontend (=browser storage) some secret user's data that shouldn't be exposed to backend. Secret key for example or anything like that. This code allows to developer to convert any `Seq[Array[Byte]]` from frontend to URL as simple call `FileService.createURL`, asynchronously convert any uploaded `File` to `Future[Array[Byte]]` as `FileService.asBytesArray`, or to `Array[Byte]` via `FileService.asSyncBytesArray` inside worker. Unfortunately scalatags doesn't support `download` attribute and I need to make it by hand. I've opened a PR[^1] to introduce it, but it might be a while until it is included to release. `FileService.asSyncBytesArray` is using `FileReaderSync` that is also missed inside scala-js-dom. I've opened a PR[^2] but it might be a while. Also, this draft API but it is supported by majority of modern browsers[^3]. [^1]: com-lihaoyi/scalatags#212 [^2]: scala-js/scala-js-dom#424 [^3]: https://caniuse.com/?search=FileReaderSync
The usecase of this code is something like this: let image that user is making a protonmail or any another application where content inside frontend (=browser storage) some secret user's data that shouldn't be exposed to backend. Secret key for example or anything like that. This code allows to developer to convert any `Seq[Array[Byte]]` from frontend to URL as simple call `FileService.createURL`, asynchronously convert any uploaded `File` to `Future[Array[Byte]]` as `FileService.asBytesArray`, or to `Array[Byte]` via `FileService.asSyncBytesArray` inside worker. Unfortunately scalatags doesn't support `download` attribute and I need to make it by hand. I've opened a PR[^1] to introduce it, but it might be a while until it is included to release. `FileService.asSyncBytesArray` is using `FileReaderSync` that is also missed inside scala-js-dom. I've opened a PR[^2] but it might be a while. Also, this draft API but it is supported by majority of modern browsers[^3]. [^1]: com-lihaoyi/scalatags#212 [^2]: scala-js/scala-js-dom#424 [^3]: https://caniuse.com/?search=FileReaderSync
The usecase of this code is something like this: let image that user is making a protonmail or any another application where content inside frontend (=browser storage) some secret user's data that shouldn't be exposed to backend. Secret key for example or anything like that. This code allows to developer to convert any `Seq[Array[Byte]]` from frontend to URL as simple call `FileService.createURL`, asynchronously convert any uploaded `File` to `Future[Array[Byte]]` as `FileService.asBytesArray`, or to `Array[Byte]` via `FileService.asSyncBytesArray` inside worker. Unfortunately scalatags doesn't support `download` attribute and I need to make it by hand. I've opened a PR[^1] to introduce it, but it might be a while until it is included to release. `FileService.asSyncBytesArray` is using `FileReaderSync` that is also missed inside scala-js-dom. I've opened a PR[^2] but it might be a while. Also, this draft API but it is supported by majority of modern browsers[^3]. [^1]: com-lihaoyi/scalatags#212 [^2]: scala-js/scala-js-dom#424 [^3]: https://caniuse.com/?search=FileReaderSync
b1092da
to
23c4c43
Compare
src/main/scala/org/scalajs/dom/experimental/FileReaderSync.scala
Outdated
Show resolved
Hide resolved
I'm not up to speed with how experimental stuff is handled in this library yet. Revisit soon'ish.... |
@japgolly I'm using for more than a year a fork which is contains this branch ;) |
Ah, I'm wrong. I'm using only |
@japgolly I think it's fine for this to live in the For 2.x, is this even still considered experimental? I didn't see any indication of such at https://developer.mozilla.org/en-US/docs/Web/API/FileReaderSync. |
ba86d9e
to
e0a2c6a
Compare
src/main/scala/org/scalajs/dom/experimental/FileReaderSync.scala
Outdated
Show resolved
Hide resolved
@armanbilge Ok if you're cool with it I'm cool with it. Let's keep it in |
Merged, thanks for the PR @catap ! |
No description provided.