-
Couldn't load subscription status.
- Fork 37
FileService: a way to work with file at frontend #656
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
Conversation
e92d4bc to f3ac0f6 Compare There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the contribution, it's surely a tricky API use case we could cover for future users. It needs some more love before we ship it.
f3ac0f6 to 762c992 Compare | @ddworak I have no idea when to revoke this URL. If you have some, feel free to share. |
9a7f575 to 93b95be Compare e223de8 to 414b03f Compare 414b03f to 53a6021 Compare guide/guide/.js/src/main/scala/io/udash/web/guide/views/frontend/demos/FileInputDemo.scala Show resolved Hide resolved
guide/guide/.js/src/main/scala/io/udash/web/guide/views/frontend/demos/FileInputDemo.scala Outdated Show resolved Hide resolved
guide/guide/.js/src/main/scala/io/udash/web/guide/views/frontend/demos/FileInputDemo.scala Outdated Show resolved Hide resolved
53a6021 to 5e2b8ed Compare 0d90a27 to 46da6eb Compare 46da6eb to d950c0c Compare guide/guide/.js/src/main/scala/io/udash/web/guide/views/frontend/demos/FileInputDemo.scala Outdated Show resolved Hide resolved
guide/guide/.js/src/main/scala/io/udash/web/guide/views/frontend/demos/FileInputDemo.scala Show resolved Hide resolved
d950c0c to 9b86e13 Compare 9b86e13 to 0111442 Compare There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM with minor rename, thanks!
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
0111442 to 9c1d9a2 Compare | @ddworak pushed renaming. |
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 callFileService.createURL, asynchronously convert any uploadedFiletoFuture[Array[Byte]]asFileService.asBytesArray, or toArray[Byte]viaFileService.asSyncBytesArrayinside worker.Unfortunately scalatags doesn't support
downloadattribute and I need to make it by hand. I've opened a PR1 to introduce it, but it might be a while until it is included to release.FileService.asSyncBytesArrayis usingFileReaderSyncthat is also missed inside scala-js-dom. I've opened a PR2 but it might be a while. Also, this draft API but it is supported by majority of modern browsers3.Footnotes
https://github.com/lihaoyi/scalatags/pull/212 ↩
https://github.com/scala-js/scala-js-dom/pull/424 ↩
https://caniuse.com/?search=FileReaderSync ↩