通常イメージは、LANSA リポジトリの外部リソースまたはビットマップとして、またはファイルの BLOB としてデーターベースに保存されていたり、単にアプリケーション・サーバー上のファイルである場合もあるでしょう。どのような形で保存されていたとしても、サーバー・モジュール内のイメージにアクセスし、要求側のクライアントに渡すために BLOB として割り当てなければいけません。
SrvRoutine Name(GetImage)
Field_Map For(*output) Field(#xEmployeeImage)
Field_Map For(*output) Field(#xEmployeeImageThumbnail)
Field_Map For(*output) Field(#XEmployeeImageMidSize)
* BLOB コンテンツをファイルの場所に設定
#xEmployeeImageThumbnail := 'C:\Users\User1\Pictures\LANSA\Employee00987tb.gif'
* BLOB コンテンツを外部リソースに設定
#xEmployeeImage := #Employee00987.FileName
* BLOB コンテンツをビットマップに設定
#xEmployeeImage := #EmpImage00987.FileName
Endroutine
逆にクライアント側からイメージを選択してデーターベースに保存する場合は、PRIM_WEB.FilePicker を使用して、Web ページで以下のように使用します。
Define_Com Class(#PRIM_WEB.FilePicker) Name(#FilePicker) Displayposition(3) Ellipses(Word) Height(56) Parent(#COM_OWNER) Tabposition(1) Tabstop(False) Top(6) Verticalalignment(Center) Width(169) Image(#xImageCamera32) Caption('Select an Image')
Define_Com Class(#PRIM_IMAG) Name(#Image) Displayposition(4) Left(191) Parent(#COM_OWNER) Tabposition(2) Tabstop(False) Top(6) Height(788) Width(800)
Define_Com Class(#PRIM_LABL) Name(#Filename) Displayposition(1) Ellipses(Word) Height(55) Left(197) Parent(#COM_OWNER) Tabposition(4) Tabstop(False) Top(733) Verticalalignment(Center) Width(800)
Evtroutine Handling(#FilePicker.FileSelected) File(#File)
Define_Com Class(#MyServerMod.SaveImage) Name(#SaveImage)
* 選択されたイメージをページに表示
#Filename := #File.Name
#Image.FileName #xDemoblob := #File.Blob
* イメージをデーターベースに保存
#SaveImage.ExecuteAsync( #File.Blob )
Endroutine