CLOB Data on iSeries
Posted: Thu Aug 24, 2017 4:36 am
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
Then in my Server Module I put it all back together and insert it into the file:
To View the Image I am doing the following in the Server Module:
And then I am preparing it for the screen as this:
A few more helpful tidbits:
Best,
Chad
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
EndroutineCode: 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
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)
EndroutineCode: 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
- When I select the record in the test application it acts like its trying to load
- I can preview the re-assembled CLOB data
Best,
Chad