panel.widgets.FileInput maximum file size?

After doing some testing, it looks like this widget will not open a file larger than about 4 MB. Is this by design? Is there a way to change the maximum file size?

temp = pn.widgets.FileInput()

There is certainly no limit hardcoded anywhere so this is likely some restriction either by the browser or the websocket communicating that data back to Python. Might be good to file an issue about this so it can be investigated further.

See #1559 for a workaround

there is a workaround at: #1559

1 Like

Many thanks to @greg_nordin and @okz for this discussion as it helped me a lot, though it didn’t directly solve my problem.
I thought it was a file size problem but it wasn’t directly.

I had implemented a watcher to trigger off a change in the FileInput widget and then have a callback function.
I triggered off “filename” but this was causing a timing issue where my callback function was called when the filename had changed but the file had not loaded and therefore the FileInput.value was None causing an error in my function.
Smaller files would load fast enough not to cause a problem but as the files were larger the timing would be out.

So for example

file_input = pn.widgets.FileInput()

def new_file_selected(selection):
    ''' Process the file somehow
   print(len(selection.obj.value)), "filename", onlychanged=False)

This would throw an error as due to the timing for a larger file value is still None as it hadn’t finished loading.
Changing to watch “value” and then all is fine as it won’t trigger until the file has loaded., “value”, onlychanged=False)

Hopefully, that may help someone who accidentally gets themselves into the same bind I did.

1 Like