Skip to content

Commit

Permalink
Multiple files in FileInput (#1911)
Browse files Browse the repository at this point in the history
* Multiple files in FileInput

Update input.py to add 'multiple' parameter to FileInput
paramenter filename can be a string or a list
parameter mime_type can be a string or a list
_process_property_change accounts for either a string or a list as input for 'msg'

* Update input.py

* Correct the default to False

Changed the default to False to avoid breaking compatibility
  • Loading branch information
miliante authored and philippjfr committed Jan 18, 2021
1 parent 09f7a12 commit d3f5207
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions panel/widgets/input.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,12 +58,16 @@ class FileInput(Widget):

accept = param.String(default=None)

filename = param.String(default=None)
filename = param.ClassSelector(default=None, class_=(str, list),
is_instance=True)

mime_type = param.String(default=None)
mime_type = param.ClassSelector(default=None, class_=(str, list),
is_instance=True)

multiple = param.Boolean(default=False)

value = param.Parameter(default=None)

_widget_type = _BkFileInput

_source_transforms = {'value': "'data:' + source.mime_type + ';base64,' + value"}
Expand All @@ -85,7 +89,10 @@ def _filter_properties(self, properties):
def _process_property_change(self, msg):
msg = super(FileInput, self)._process_property_change(msg)
if 'value' in msg:
msg['value'] = b64decode(msg['value'])
if isinstance(msg['value'], string_types):
msg['value'] = b64decode(msg['value'])
else:
msg['value'] = [b64decode(content) for content in msg['value']]
return msg

def save(self, filename):
Expand Down

0 comments on commit d3f5207

Please sign in to comment.