Page 1 of 1
VL-Web file upload example
Posted: Wed Jan 04, 2017 8:01 pm
by Jiri
Is there some VL-Web file upload example? Both methods of file selection (via filepicker or via drag end drop) are required.
Re: VL-Web file upload example
Posted: Thu Jan 05, 2017 12:30 am
by Stewart Marshall
Hi Jiri
xDemoWebImageCapture shows how a file can be selected and then stored in a blob. This can then be sent to the server the same as any other field.
Drag and drop is not supported currently as a result of limited browser support.
A simple server routine to receive and manage a file might be coded as below
Code: Select all
Srvroutine Name(FileUpload)
Field_Map For(*Input) Field(#xDemoBlob) Parameter_Name(File)
Field_Map For(*Input) Field(#xDemoAlpha128) Parameter_Name(FileName)
Field_Map For(*Output) Field(#xDemoAlpha256) Parameter_Name(SavedTo)
* Move the temporary BLOB file to a permanent home
If (#Utilities.CopyFile( #xDemoBlob.FileName (*Part_Dir_Object + #xDemoAlpha128) ))
#xDemoAlpha256 := *Part_Dir_Object + #xDemoAlpha128
Endif
Endroutine
Regards
Re: VL-Web file upload example
Posted: Tue Feb 14, 2017 4:55 am
by Jiri
I have related question - how to present the saved file back to client? In WAM, there was a special type of webroutine RESPONSE(*HTTPR), which was used for it.
In VL_WEB, I can have srvroutine like this:
Srvroutine Name(GET_DOC)
Field_Map For(*INPUT) Field(#DocID) Parameter_Name(ReqDocID)
Field_Map For(*OUTPUT) Field(#xDemoBlob) Parameter_Name(RetFile)
Fetch Fields(#xDemoBlob) From_File(DMSImages) With_Key(#DocID)
Endroutine
If the file is always image (as in example xEpmployeeImages) it can be presented as image or in list. But if the object is document (which can be .PDF, .DOC or image .jpg etc) how to present the response blob on client? As I mentioned, in WAMs response(*HTTPR) was used and fine - what similar technique can be used in VL-Web?
Re: VL-Web file upload example
Posted: Tue Feb 14, 2017 5:37 am
by Stewart Marshall
Hi Jiri
Have a look at xDemoWebImageDownload.
This returns the Blob as an object rather than just a variable.
Regards
Re: VL-Web file upload example
Posted: Tue Feb 14, 2017 9:29 pm
by Jiri
Thanks, the example is fine.
Is somewhere some more detail documentation about the RESPONSE usage? I have found reference to mentioned code (
http://docs.lansa.com/14/en/lansa017/co ... 1_0545.htm ) and response class
http://docs.lansa.com/14/EN/LANSA016/PR ... sponse.htm, but I would welcome more examples using another response properties.
Re: VL-Web file upload example
Posted: Wed Feb 15, 2017 8:58 am
by MarkD
The just released EPC141017 VLF-ONE version has 4 upload and download examples:
http://docs.lansa.com/14/en/lansa048/in ... 7_0115.htm
The shipped example code is easily reused outside of the VLF-ONE container.