While uploading a geojson file through FileUploadField by providing accept parameter, the resulting file dialog only shown *.com, *.exe, *.bin files. Though it is working fine with *.doc and *.xls files. Can it be fixed? Please guide.
Hi, @vimleshjaipur
I tried to reproduce this case using Jmix 2.3 and it works with the following component declaration in the view descriptor:
<fileUploadField acceptedFileTypes=".geojson"/>
In this case, the upload dialog shows the files with the .geojson
extension only.
Could you please clarify what Jmix version is used and provide the sample project where the problem can be reproduced?
Regards,
Maria.
Thanks for the reply. We are using JMIX version 1.5.4. The XML used for fileStorageUpload field is as below;
<fileStorageUpload caption="GeoJSON File" id="fileField" showFileName="true" fileStoragePutMode="MANUAL" required="true" accept="*.geojson" permittedExtensions=".geojson"/>
It is working well from doc and xls files. Please guide.
@vimleshjaipur I reproduced your case and got the same result because the FileStorageUploadField
component converts provided value to the allowed MIME type and if the extension is unknown, the default MIME type (application/octet-stream
) is set. So that’s why you get .bin
, .exe
and other as allowed extensions.
Workaround for your case is to set an allowed extension programmatically in the internally used component.
Component declaration in the screen descriptor:
<fileStorageUpload id="fileField" caption="GeoJSON File" showFileName="true"
fileStoragePutMode="MANUAL" required="true" permittedExtensions=".geojson"/>
Code in the screen controller:
@Autowired
private FileStorageUploadField fileField;
@Subscribe
public void onInit(final InitEvent event) {
fileField.withUnwrapped(JmixFileUploadField.class, uploadField -> uploadField.setAccept(".geojson"));
}
Regards,
Maria.
Thanks Maria. It is working now. Thanks again.