Skip to content
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

refactor file handling in WASM wrapper #872

Merged
merged 1 commit into from
Oct 3, 2024

Conversation

hanayik
Copy link
Collaborator

@hanayik hanayik commented Oct 2, 2024

This PR refactors the file handling in the JavaScript wrapper to allow similar behaviour when files come from <input> html elements using webkitdirectory and when files come from users drag and drop events where the files will be from event.dataTransfer.items.

Unfortunately, the latter case requires some custom event handling by the downstream developer to recursively read files from directories.

We have this same constraint in Niivue, but we attach event handlers directly to the canvas element there. In the case of dcm2niix, it does not care about html elements or their events, so that handling has to be taken care of prior to passing files in.

The changes in this PR make that process slightly less painful though.

two new methods on the Dcm2niix class are available:

  • inputFromWebkitDirectory
  • inputFromDropItems
  • also: file from event.dataTransfer.items (i.e. dropped files) must have the custom property _webkitRelativePath appended.

This all works, and is demonstrated in the live demo here: https://niivue.github.io/niivue-dcm2niix/

and in the demo web app repo here: https://github.com/niivue/niivue-dcm2niix

@neurolabusc neurolabusc merged commit 15b5356 into development Oct 3, 2024
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants