viur-framework/viur-vi

File upload not working with Pyodide 0.19

phorward opened this issue · 2 comments

There is a proxy required.

Uncaught PythonError: Traceback (most recent call last):
  File "/lib/python3.9/site-packages/flare/network.py", line 103, in onReadyStateChange
    self.callbackSuccess(self.req.responseText)
  File "/lib/python3.9/site-packages/flare/network.py", line 499, in onCompletion
    s(self)
  File "/lib/python3.9/site-packages/vi/widgets/file.py", line 184, in onUploadUrlAvailable
    html5.window.fetch(params["uploadUrl"], **{"method": "POST", "body": req.file, "mode": "no-cors"}).then(
AttributeError: 'Future' object has no attribute 'then'

Regarding #86 (which is already implemented this way in current main) the use of fetch or pyfetch is required, but not possible at the moment. I've started a discussion at pyodide on this problem. HTTPRequest from Flare can't be used as it uses XMLHttpRequest which doesn't implement a mode for "no-cors".

Fixed with 5cab860