Hi
I move pdf,img etc to a blob field in a table. I make a list of files with the OV_FILE_SERVICE on the IBM I's IFS and the insert it to a table with a blob field. When i try to get the mime type from the blob i a View it says that the mime type is APPLICATION/OCTET-STREAM. Now I can not show the blob in the correct way - I have expected JPG or PDF etc.
Does anybody have a solution for this issue?
/klaus
APPLICATION/OCTET-STREAM on BLOB LANSA V150050
Re: APPLICATION/OCTET-STREAM on BLOB LANSA V150050
Hi Klaus,
I don't think the OV_FILE_SERVICE GET_DIR have anything to do with, as that will just give you a list of files in a dir and once you know what file it is, you will have to basically do this:
if I create a server routine like this, which puts a file from the ifs in a blob field, then stores in a file, put the blob field in null, then reads the blob field from the table TMPBLOB which is just a table with 2 fields, EMPNO as key and STD_BLOB:
I still get the mimetype correct... it is not lost after storing in a table.
testing with a web page like this:
Can you try this code with your files?
I don't think the OV_FILE_SERVICE GET_DIR have anything to do with, as that will just give you a list of files in a dir and once you know what file it is, you will have to basically do this:
Code: Select all
#STD_BLOB := '/tmp/ibmpseries.jpg'Code: Select all
Srvroutine Name(getoneblob)
Field_Map For(*OUTPUT) Field(#std_blob)
#STD_BLOB := '/tmp/ibmpseries.jpg'
#EMPNO := "A1111"
Insert Fields(#EMPNO #STD_BLOB) To_File(TMPBLOB)
If_Status Is_Not(*OKAY)
Update Fields(#STD_BLOB) In_File(TMPBLOB) With_Key(#EMPNO)
Endif
#STD_BLOB := *NULL
Fetch Fields(#STD_BLOB) From_File(TMPBLOB) With_Key(#EMPNO)
Endroutinetesting with a web page like this:
Code: Select all
Begin_Com Role(*EXTENDS #PRIM_WEB) Theme(#SYS_THEME<MaterialDesignBlue>)
Define_Com Class(#PRIM_IMAG) Name(#Image) DisplayPosition(1) Image(#xImageImage32) ImageSizing(BestFit) Left(48) Parent(#COM_OWNER) TabPosition(1) TabStop(False) Top(24) Height(305) Width(393)
Define_Com Class(#STD_STRNG.EditField) Name(#STD_STRNG) DisplayPosition(2) Left(52) Parent(#COM_OWNER) TabPosition(2) Top(377) Width(397)
Evtroutine Handling(#COM_OWNER.Initialize)
* #COM_OWNER.FindFiles
Define_Com Class(#test630sm.getoneblob) Name(#getoneblob)
#getoneblob.Execute std_blob(#STD_BLOB)
#Image.Image <= #SYS_APPLN.CreateBitmap( #STD_BLOB )
#STD_STRNG := #STD_BLOB.MimeType
Endroutine
End_ComRe: APPLICATION/OCTET-STREAM on BLOB LANSA V150050
Hi Dino.
I have now tested your code. And it works.
I have tried to make some changes so it looks more like my use. If you change the servermodul to something like this:
Srvroutine Name(Initblob)
Field_Map For(*OUTPUT) Field(#std_blob)
#STD_BLOB := '/tmp/ibmpseries.jpg'
#EMPNO := "A1111"
Insert Fields(#EMPNO #STD_BLOB) To_File(TMPBLOB)
If_Status Is_Not(*OKAY)
Update Fields(#STD_BLOB) In_File(TMPBLOB) With_Key(#EMPNO)
Endif
#STD_BLOB := *NULL
Fetch Fields(#STD_BLOB) From_File(TMPBLOB) With_Key(#EMPNO)
Endroutine
Srvroutine Name(GetOneblob)
Field_Map For(*OUTPUT) Field(#std_blob)
#EMPNO := "A1111"
#STD_BLOB := *NULL
Fetch Fields(#STD_BLOB) From_File(TMPBLOB) With_Key(#EMPNO)
Endroutine
Make your Initialize routine call the initBlob and add a button to your page and make it call Getoneblob.
First time (after the Initialize routine) the mime type is correct, but if you hit the button and it only reads the blob then the type is application/octet-stream.
What is the differance?
I have now tested your code. And it works.
I have tried to make some changes so it looks more like my use. If you change the servermodul to something like this:
Srvroutine Name(Initblob)
Field_Map For(*OUTPUT) Field(#std_blob)
#STD_BLOB := '/tmp/ibmpseries.jpg'
#EMPNO := "A1111"
Insert Fields(#EMPNO #STD_BLOB) To_File(TMPBLOB)
If_Status Is_Not(*OKAY)
Update Fields(#STD_BLOB) In_File(TMPBLOB) With_Key(#EMPNO)
Endif
#STD_BLOB := *NULL
Fetch Fields(#STD_BLOB) From_File(TMPBLOB) With_Key(#EMPNO)
Endroutine
Srvroutine Name(GetOneblob)
Field_Map For(*OUTPUT) Field(#std_blob)
#EMPNO := "A1111"
#STD_BLOB := *NULL
Fetch Fields(#STD_BLOB) From_File(TMPBLOB) With_Key(#EMPNO)
Endroutine
Make your Initialize routine call the initBlob and add a button to your page and make it call Getoneblob.
First time (after the Initialize routine) the mime type is correct, but if you hit the button and it only reads the blob then the type is application/octet-stream.
What is the differance?