APPLICATION/OCTET-STREAM on BLOB LANSA V150050

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
kno_dk
Posts: 221
Joined: Tue Feb 23, 2016 12:00 am

APPLICATION/OCTET-STREAM on BLOB LANSA V150050

Post by kno_dk »

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
User avatar
Dino
Posts: 477
Joined: Fri Jul 19, 2019 7:49 am
Location: Robbinsville, NC
Contact:

Re: APPLICATION/OCTET-STREAM on BLOB LANSA V150050

Post by Dino »

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:

Code: Select all

#STD_BLOB := '/tmp/ibmpseries.jpg'
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:

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)
Endroutine
I still get the mimetype correct... it is not lost after storing in a table.

testing 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_Com
mimetype01.jpg
mimetype01.jpg (74.46 KiB) Viewed 10606 times
Can you try this code with your files?
kno_dk
Posts: 221
Joined: Tue Feb 23, 2016 12:00 am

Re: APPLICATION/OCTET-STREAM on BLOB LANSA V150050

Post by kno_dk »

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?
Post Reply