I have a testcase in which the getUploadedFileStream() is not behaving as stated in the docs.
EntryPoint:
It just selects a document with f_id=85. You have to have a table with this id and with f_datei as binary.
testingDS.ds.xml:
TestingDMI:
If you open the application and don't upload any file, so just press the button "save", you will get this output:
According to the docs: https://www.smartclient.com/smartgwt...a.lang.String-
"InputStream representing uploaded file for specified field, or null if no file was uploaded for the specified field."
So the uploaded stream should be null.
Please check this. I was relying in this and my client has lost a lot of data because of this behavior.
Using 6.1-p20171105 power
EntryPoint:
Code:
public void onModuleLoad() { final VLayout vlayout = new VLayout(10); final DynamicForm editDokumenteForm = new DynamicForm(); editDokumenteForm.setDataSource("testingDS"); editDokumenteForm.setHeight("62%"); editDokumenteForm.setWidth("100%"); editDokumenteForm.setNumCols(2); editDokumenteForm.setColWidths("40%", "60%"); editDokumenteForm.setPadding(5); FileItem fileItem = new FileItem("f_datei", "Datei"); fileItem.setHeight(20); editDokumenteForm.setFields(fileItem); vlayout.addMember(editDokumenteForm); IButton saveButton = new IButton("Save"); vlayout.addMember(saveButton); saveButton.addClickHandler(new ClickHandler() { @Override public void onClick(ClickEvent event) { editDokumenteForm.saveData(new DSCallback() { @Override public void execute(DSResponse dsResponse, Object data, DSRequest dsRequest) { SC.say("Saved"); } }); } }); Criteria c = new Criteria(); c.addCriteria("f_id", 85); editDokumenteForm.fetchData(c); vlayout.draw(); }
testingDS.ds.xml:
Code:
<DataSource ID="testingDS" serverType="sql" tableName="t_dokumente"> <fields> <field name="f_id" type="sequence" primaryKey="true" /> <field name="f_datei" type="binary" maxFileSize="10485760" /> <field name="f_datei_filename" type="text" /> <field name="f_datei_date_created" type="date" /> <field name="f_datei_filesize" type="integer" /> </fields> <operationBindings> <operationBinding operationType="update"> <serverObject className="de.mks_infofabrik.kids.server.test.TestingDMI" methodName="testMethod" /> </operationBinding> </operationBindings> </DataSource>
Code:
public class TestingDMI { private static final Logger LOG = Utils.getLogger(TestingDMI.class); public DSResponse testMethod(DSRequest dsRequest) throws Exception { LOG.info("TestingDMI: ExecuteMethod()"); Map<String, Object> values = dsRequest.getValues(); LOG.info("values.get(\"f_datei\") " + values.get("f_datei")); LOG.info("Uploaded stream: " + dsRequest.getUploadedFileStream("f_datei")); return new DSResponse(); } }
Code:
=== 2017-11-29 13:54:47,203 [ec-6] INFO TestingDMI - TestingDMI: ExecuteMethod() === 2017-11-29 13:54:47,204 [ec-6] INFO TestingDMI - values.get("f_datei") null === 2017-11-29 13:54:47,204 [ec-6] INFO TestingDMI - Uploaded stream: java.io.ByteArrayInputStream@7053707
According to the docs: https://www.smartclient.com/smartgwt...a.lang.String-
"InputStream representing uploaded file for specified field, or null if no file was uploaded for the specified field."
So the uploaded stream should be null.
Please check this. I was relying in this and my client has lost a lot of data because of this behavior.
Using 6.1-p20171105 power
Comment