IFS to BLOB
Posted: Wed Apr 05, 2017 4:53 pm
I have images stored in the iSeries IFS which I wish to retrieve in my Server Module as BLOBs. Is there a simple way of converting a file path into a blob?
Code: Select all
FUNCTION OPTIONS(*DIRECT)
DEFINE_COM CLASS(#prim_alph) NAME(#wkDire)
DEFINE_COM CLASS(#prim_alph) NAME(#pDir)
DEFINE_COM CLASS(#prim_alph) NAME(#pFile)
DEFINE FIELD(#w_name) TYPE(*CHAR) LENGTH(50)
DEFINE FIELD(#w_prefix) TYPE(*char) LENGTH(16)
DEFINE FIELD(#w_suffix) TYPE(*char) LENGTH(3)
DEFINE FIELD(#w_date) TYPE(*char) LENGTH(8)
DEFINE FIELD(#w_time) TYPE(*char) LENGTH(6)
DEFINE FIELD(#w_isdir) TYPE(*char) LENGTH(1)
DEFINE FIELD(#w_size) TYPE(*dec) LENGTH(9) DECIMALS(0)
DEF_LIST NAME(#directory) FIELDS(#w_name #w_prefix #w_suffix #w_date #w_time #w_size #w_isdir) COUNTER(#listcount) TYPE(*WORKING) ENTRYS(*max)
CLR_LIST NAMED(#directory)
#pDir := 'L:\Images\'
* Set image type for Database
#pFile := 'EMPLOYEES'
USE BUILTIN(OV_FILE_SERVICE) WITH_ARGS(GET_DIR #pDir) TO_GET(#r_status #r_winsts #directory)
IF (#r_status ^= OK)
RETURN
ENDIF
SELECTLIST NAMED(#directory)
IF ((#w_name.upperCase.Contains( '.JPG' )))
#wkDire := #pDir + '\' + #w_Name
#audFnm := #pFile
#audFid := #w_prefix
#audSeq := 1
* this is blob field
#lwiImage := #wkDire
CHECK_FOR IN_FILE(lwimages01) WITH_KEY(#audFnm #audFid)
IF_STATUS IS_NOT(*equalKey)
#audId := *AUTONUM08XXXNXTID2
INSERT FIELDS(#audID #audFnm #audFid #audSeq #lwiImage #createdby #createdDt #createdTm) TO_FILE(lwImages)
#std_Count += 1
ENDIF
ENDIF
ENDSELECT
MESSAGE MSGTXT('Total Images in Directory ' + #listCount.asString)
MESSAGE MSGTXT('Total Images added ' + #std_Count.asString)