container2wasm icon indicating copy to clipboard operation
container2wasm copied to clipboard

Mounting files into the container in the browser?

Open adamnovak opened this issue 1 year ago • 2 comments

An example is given for mounting files into the container when running on a stand-alone WASI runner, but not in the context of the browser.

If I have a File or a Blob in hand in JavaScript when I am setting up the emulator, how would I expose that to the container at a certain path?

Bonus points if I can also mount something writable, like a resizable ArrayBuffer.

adamnovak avatar Jan 03 '24 18:01 adamnovak

I am wondering the exact same thing, would be wonderful if we had the ability to attach files to a container in the browser

alienself avatar Jan 03 '24 23:01 alienself

@adamnovak For container on WASI on browser configuration, you can provide file or directories as pre-opened fds to the container .

  • Example1: w/ browser_wasi_shim : https://github.com/ktock/container2wasm/blob/31f6db882faad0a450c56ae5966796c93e2c4520/examples/wasi-browser/htdocs/worker.js#L25-L33
  • Example2: w/ vscode-wasm : https://github.com/ktock/vscode-container-wasm/blob/26afb1790af51987687048b9bf8f16187ae7fe46/src/web/extension.ts#L76-L85

ktock avatar Jan 04 '24 00:01 ktock