You are here: Web Apps with Visual LANSA > 9. Displaying Images > 9.2 Storing Image in the Database as Blobs > 9.2.2 Download a Blob

9.2.2 Download a Blob

Rather than having to submit a download request per image, Visual LANSA allows Blobs to be included as a field in a working list.

When managed in this way, the Blob data is converted to a Base64 encoded string that is passed as part of the JSON. This is then converted back to images when it arrives at the client.

Visual LANSA manages images such as these as Data Objects in the JavaScript. This allows for simple manipulation in LANSA, but is not recommended for large numbers of large images as it is a relatively expensive in terms of memory use. However, this technique is an excellent solution for thumbnails and other small images.

The routine below demonstrates how many Blob images can be returned to the client with a single request.

Def_List Name(#employees) Fields(#xEmployeeIdentification #xEmployeeSurname #xEmployeeGivenNames #xEmployeeStreet #xEmployeeCity #xEmployeeState #xEmployeePostalCode #xEmployeeHomeTelephone #xEmployeeBusinessTelephone #XDepartmentCode #xEmployeeSalary #xEmployeeStartDate #xEmployeeTerminationDate #xEmployeeImageThumbnail) Type(*working) Entrys(*Max)
SrvRoutine Name(GetEmployees) Response(*JSON)
List_Map For(*Output) List(#Employees)
* Get all employee data
Select Fields(#employees) From_File(xEmployee)
* Get the employ


ee thumbnail image.  Stored as a Blob
Fetch Fields(#xEmployeeImageThumbnail) From_File(xEmployeeImages) With_Key(#xEmployeeIdentification)
Add_Entry To_List(#Employees)