1

I'm using Pyodide and I have several files in the Pyodide file system. I try to implement the following behavior :

  • the user click on a button to download a specific file from the Pyodide file system
  • the download starts

The file to be downloaded is a zip file.

I read the file with:

let file = pyodide.FS.readFile('/home/pyodide/assets/test.zip', { encoding: "utf8" });

And I try to save it with FileSaver.js :

saveAs(file, 'test.zip');

But the download doesn't work.

Peter Estiven
  • 414
  • 1
  • 7
  • 16
  • 2
    The browser knows nothing about the Pyodide file system or Python functions such as `saveAs`. Python/PyScript knows nothing about the desktop local file system. You must load the file into memory, convert it into a JavaScript `Blob` and then call a browser function to write to the local desktop file system. I wrote a series of articles on Pyscript, Pyodide, file systems and JavaScript Interop that will show you how: https://www.jhanley.com/blog/category/pyscript/ – John Hanley Sep 25 '22 at 07:43

0 Answers0