Closed hxh-robb closed 6 years ago
Turn out it's not that complicated to return a file object. Just override the getValue
function to return the element.files[0]
instead of element.value
of the file input element in the decorator, then the bf.getData()
will return a object instead of the file path string.
Following is the example: https://jsfiddle.net/hxh_robb/xk663z01/5/
The value of file field from bf.getData()
is not the original File
DOM object returned by the overridden element.getValue()
but a raw object. That's because brutusin makes a properties clone recursively in bf.getData()
, it replaces the original value with a new clone object.
I've created a PR to fix this issue.
We can use decorator to render a field as a file input, but when we use
bf.getData()
, the value of this field is a string of file path, not a file object.And I've taken a look at the upload demo from Brutusin-RPC, it made an extension function named
bf.getFileMap()
.I think it's better to make a native support in json forms.