Page 1 of 1

CLOB Data on iSeries

Posted: Thu Aug 24, 2017 4:36 am
by lawingo
I'm working on a simple VL-Web project of capturing an image via tablet(Camera Control Widget) and saving the image to an iSeries File as CLOB data. I have a pre-existing identical project that works but the data is saved in a Windows SQL Server. I assume once I have the CLOB data saved I should be able to retrieve it and view it on the Web as well as any regular VL application that is running against the iSeries. I have created a test application for each but I can't get the image to show in either one.
I save the image data into a CLOB by deconstructing the base64 data into 65000 byte chunks

Code: Select all

Evtroutine Handling(#CameraControl.Completed) Base64data(#base64) File(#file)
* Define_Com Class(#EMEM_SM01.InsertEMEM) Name(#EMEMInsert)

* #SYS_WEB.Alert Caption(#base64)
#Image1.FileName := #base64
#W_LENGTH := #base64.CurSize

Clr_List Named(#L_IMG64)
#W_START := 1
#W_END := 65000
Dountil Cond(#W_END = #W_LENGTH)

#W_BLOBH := #base64.Substring( #W_START #W_END )
Add_Entry To_List(#L_IMG64)

#W_START := #W_START + 65000
#W_END := #W_END + 65000

If Cond(#W_END > #W_LENGTH)
#W_END := #W_LENGTH
#W_BLOBH := #base64.Substring( #W_START #W_END )
Add_Entry To_List(#L_IMG64)
Leave

Endif

Enduntil



Endroutine
Then in my Server Module I put it all back together and insert it into the file:

Code: Select all

Srvroutine Name(InsertEMEM)
List_Map For(*INPUT) List(#L_EMEM) Parameter_Name(TheList)
List_Map For(*INPUT) List(#L_IMG64) Parameter_Name(ImgList)

Field_Map For(*OUTPUT) Field(#EMEMID) Parameter_Name(id)
Field_Map For(*OUTPUT) Field(#W_STATUS) Parameter_Name(Status)

Get_Entry Number(1) From_List(#L_EMEM)

#EMEMID := 0

Use Builtin(STM_FILE_OPEN) With_Args('/tmp/EMEM.txt' 'Write LineTerminator=NONE') To_Get(#STSTGRJP)
* Use Builtin(STM_FILE_OPEN) With_Args('c:\temp\emem.txt' 'Write LineTerminator=NONE') To_Get(#STSTGRJP)

Selectlist Named(#L_IMG64)
Use Builtin(STM_FILE_WRITE) With_Args(#STSTGRJP #W_BLOBH)
Endselect
Use Builtin(STM_FILE_CLOSE) With_Args(#STSTGRJP)

#EMEIIMG := '/tmp/EMEM.txt'
* #EMEIIMG := 'c:\temp\emem.txt'

Insert Fields(#EMEMID #EMEMDVID #EMEMCTID #EMEMDPID #EMEMJTCD #EMEMHRDT #EMEMLVDT #EMEMI_D #EMEMRATE #EMEMATFL) To_File(EMEM) Io_Status(#W_STATUS) Io_Error(*NEXT) Val_Error(*NEXT) Return_Rrn(#PRIFILRRN)

Fetch Fields(#EMEMID) From_File(EMEM) Io_Error(*NEXT) Val_Error(*NEXT) With_Rrn(#PRIFILRRN)

Insert Fields(#EMEMID #EMEIIMG) To_File(EMEI) Io_Status(#W_STATUS) Io_Error(*NEXT) Val_Error(*NEXT)

* Use Builtin(OV_FILE_SERVICE) With_Args('REMOVE_FILE' '/tmp/EMEM.txt')
* Use Builtin(OV_FILE_SERVICE) With_Args('REMOVE_FILE' 'c:\temp\emem.txt')

Endroutine
To View the Image I am doing the following in the Server Module:

Code: Select all

Srvroutine Name(GetWebImagesv2)
Field_Map For(*INPUT) Field(#EMEMID) Parameter_Name(ID)
List_Map For(*OUTPUT) List(#L_VIMG64) Parameter_Name(ImgList)

Clr_List Named(#L_VIMG64)

* Fetch Fields(#EMEMID) From_File(EMEMVU1) With_Key(#EMEMCTID) Io_Error(*NEXT) Val_Error(*NEXT)

Fetch Fields(#EMEIIMG) From_File(EMEI) With_Key(#EMEMID) Io_Error(*NEXT) Val_Error(*NEXT)
#DVDVID := #EMEMID

Use Builtin(STM_FILE_OPEN) With_Args(#EMEIIMG.FileName 'Read') To_Get(#STSTGRJP)
Dountil Cond((#FW_RETCD <> 'OK') And (#FW_RETCD <> 'OV'))
Use Builtin(STM_FILE_READ) With_Args(#STSTGRJP) To_Get(#W_BLOBH #FW_RETCD)
Add_Entry To_List(#L_VIMG64)
Enduntil
Use Builtin(STM_FILE_CLOSE) With_Args(#STSTGRJP)

#LISTCOUNT += 1
Add_Entry To_List(#L_EMEM)

Endroutine
And then I am preparing it for the screen as this:

Code: Select all

Mthroutine Name(GetDetail) Access(*PRIVATE)
Define_Map For(*INPUT) Class(#EMEMCTID) Name(#miEMEMCTID)
Define_Com Class(#emem_SM01.GetDetail) Name(#GetDetail)
Define_Com Class(#emem_SM01.GetWebImagesv2) Name(#GetImage)

#GetDetail.Execute Contactid(#miEMEMCTID) Thelist(#L_EMEM)

Get_Entry Number(1) From_List(#L_EMEM)

* Get Image
#GetImage.Execute Id(#EMEMID) Imglist(#L_VIMG64)

#base64 := *null
Selectlist Named(#L_IMG64)
#base64 := #base64 + #W_BLOBH
Endselect

* #SYS_WEB.Alert Caption(#EMEMID.AsString + ' ' + #EMEMCTID.AsSTring + ' ' + #base64)

#Image1.Image <= #SYS_APPLN.CreateBitmap( #base64 )

#Image1.FileName := #base64

Endroutine
A few more helpful tidbits:
  • When I select the record in the test application it acts like its trying to load
  • I can preview the re-assembled CLOB data
But in the end - I don't see my image. This same set up works great on the Windows Web Server but not using the iSeries. Any suggestions?

Best,
Chad

Re: CLOB Data on iSeries

Posted: Thu Aug 24, 2017 4:55 am
by dhnaigles
Chad,
Why a CLOB and not a BLOB? I have been using BLOB fields to save images from a mobile device and store them on the iSeries. Also, on what device and through what method are you displaying the image? are you putting it in an image control on a VL webpage or displaying in a #PRIM_WEB control? If it is in a #PRIM_WEB control, take a look at the discussion thread "PDF Viewer in VL Web"

Re: CLOB Data on iSeries

Posted: Thu Aug 24, 2017 5:15 am
by lawingo
The camera Control only allows Base64 Data. The File Picker allows you to save a BLOB but not the camera control widget. I would have preferred a BLOB but this was how I was advised on my original project. I have attempted to set up one method but two different platforms of displaying the image. The first being an image control within a regular VL application (my VLF). The 2nd is an image control on a VL Web page.

Re: CLOB Data on iSeries

Posted: Thu Aug 24, 2017 5:24 am
by dhnaigles
Sorry, I have not tried the camera control widget. I preferred to use the FilePicker. It works just fine on both iOS and Android devices and gave me the functionality I needed. Can I ask - Why use the camera control? Does it have some additional functionality that the FilePicker does not?

Re: CLOB Data on iSeries

Posted: Thu Aug 24, 2017 5:42 am
by lawingo
I work in Furniture Manufacturing. In my original project, the user wanted to take photos of the furniture before they were packed and shipped. Using the camera Control Widget, I was able to allow the user to take the picture and save it without saving it to the Camera Roll. This seemed important since the User was going to take at least 4 images per piece of furniture. That would add up quickly. Also, it seemed more efficient to take the image from the VL Web page than taking the image and then switching back to Lansa Mobile APP to pick the image and save it.

Regardless of the use, I have the process working with a Windows Server and it works well. I'm baffled at why its not working with our iSeries.

Re: CLOB Data on iSeries

Posted: Thu Aug 24, 2017 6:43 am
by dhnaigles
Chad
When you use the file picker on a mobile device, it gives you the option to "Take Photo or Video" and returns the BLOB to the VL Web Page. Take a look at my attachments

Re: CLOB Data on iSeries

Posted: Thu Aug 24, 2017 9:57 pm
by lawingo
Why didn't you lead with that ?? :D I'm not sure what lead me to think the FilePicker wouldn't do that. Thanks!

Re: CLOB Data on iSeries

Posted: Fri Aug 25, 2017 1:14 am
by caseywhite
In a previous post of mine here is what I had noticed with the behavior when using the File Picker. It works nicely but at least on an Android device it doesn't recognize that the picture was taken in portrait module.

The File Picker is nice in that you don't have to run it in LANSA Mobile and the coding is easier. But it seems like you don't know if the picture was taken portrait so you would have to give the user the option to rotate the picture. But since it supports BLOB the coding of passing the BLOB field to the server module and reading the BLOB field is really easy. So it could be worth considering the file picker.