9.2.3 Download a Response Variable

Images and other resources can be downloaded by passing a LOB variable as a response from the server routine. In the example below the employee details, including the BLOB, are fetched and then used as the name of the physical file object. In this instance, the image is stored in the database as a Blob, so the Response ContentFile property is set to the FileName of the Blob.

 

SrvRoutine Name(DownloadImage) Response(#Response)
Field_Map For(*Input) Field(#xEmployeeIdentification)
 
Fetch Fields(#xEmployeeSurname #xEmployeeGivenNames) From_File(xEmployee) With_Key(#xEmployeeIdentification)
 
If_Status Is(*okay)
 
Fetch Fields(#xEmployeeImage) From_File(xEmployeeImages) With_Key(#xEmployeeIdentification)
 
If_Status Is(*okay)
 
#Response.ContentFile := #xEmployeeImage.Filename
#Response.AttachmentFileName := #xEmployeeSurname +#xEmployeeGivenNames + #xEmployeeIdentification + ".jpg"
 
Endif
 
Endif
 
Endroutine