VL-Web file upload example

This Q&A forum allows users to post and respond to "How Do I Do ....." questions. Please do not use to report (suspected) errors - you must use your regional help desk for this. The information contained in this forum has not been validated by LANSA and, as such, LANSA cannot guarantee the accuracy of the information.
Post Reply
User avatar
Jiri
Posts: 45
Joined: Thu Feb 11, 2016 11:41 pm

VL-Web file upload example

Post by Jiri » Wed Jan 04, 2017 8:01 pm

Is there some VL-Web file upload example? Both methods of file selection (via filepicker or via drag end drop) are required.

User avatar
Stewart Marshall
Posts: 417
Joined: Thu Nov 05, 2015 5:25 pm

Re: VL-Web file upload example

Post by Stewart Marshall » Thu Jan 05, 2017 12:30 am

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
Stewart Marshall

Independent IT Consultant
www.marshallfloyd.com.au

User avatar
Jiri
Posts: 45
Joined: Thu Feb 11, 2016 11:41 pm

Re: VL-Web file upload example

Post by Jiri » Tue Feb 14, 2017 4:55 am

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?

User avatar
Stewart Marshall
Posts: 417
Joined: Thu Nov 05, 2015 5:25 pm

Re: VL-Web file upload example

Post by Stewart Marshall » Tue Feb 14, 2017 5:37 am

Hi Jiri

Have a look at xDemoWebImageDownload.

This returns the Blob as an object rather than just a variable.

Regards
Stewart Marshall

Independent IT Consultant
www.marshallfloyd.com.au

User avatar
Jiri
Posts: 45
Joined: Thu Feb 11, 2016 11:41 pm

Re: VL-Web file upload example

Post by Jiri » Tue Feb 14, 2017 9:29 pm

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.

MarkD
Posts: 661
Joined: Wed Dec 02, 2015 9:56 am

Re: VL-Web file upload example

Post by MarkD » Wed Feb 15, 2017 8:58 am

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.

Post Reply