44
Views
1
Comments
Displaying Binary Image from Database after using T-SQL COMPRESS/DECOMPRESS
Application Type
Reactive
Service Studio Version
11.54.17 (Build 62610)
Platform Version
11.23.1 (Build 40847)

Background:

I have an application where a user can upload images to be saved to OutSystems database (configured for Microsoft SQL Server).

Images are being saved as Binary OutSystems data-type, which translates to VARBINARY(MAX) at the SQL server.

I want to utilise/utilize the SQL Server COMPRESS and DECOMPRESS functionality to ensure that I am making efficient usage of my database space.

I have created a POC (proof of concept) application module to test both the potential space saving I could receive, as well as the ability to view images from the database (after the DECOMPRESS).

This POC is included as .oml file attached.

Issue:

The Reactive Gallery Images are not displaying the Binary Image file data.

Code Explaination:

For the POC I am saving images to two database tables, one table is saving the uncompressed image binary, the other saves the compressed image binary.

Two screens: 

UploadImage has an Upload Widget and a 'Save' Button.
Save button calls server action where I save the image Binary, FileName, and current datetime into separate entities.

ViewImage has a Tab Widget with two tabs. Both tabs contain a Gallery Widget.
Gallery List for Uncompressed images has a screen aggregate to fetch data from the UncompressedImages entity. Each Image in the gallery is set to use type Binary Data.
Gallery List for Compressed images fetches data using Advanced SQL block within a 'Fetch Data From Other Sources' output. [so that the Advanced SQL block can use the DECOMPRESS SQL function].

Resources:

https://learn.microsoft.com/en-us/sql/t-sql/functions/compress-transact-sql?view=sql-server-ver16
https://learn.microsoft.com/en-us/sql/t-sql/functions/decompress-transact-sql?view=sql-server-ver16

Desired Output:

I know that there are better places than SQL server to save images, so please do not suggest that as an answer - what I want to understand is why the Binary data from my compressed images is not displaying in the Reactive Image block.

I have debugged through and done comparisons of the binary data between my uncompressed and compressed lists and these are both identical.

Looking forward to your help and suggestions! :) 

Mike_Testing_Reactive.oml
UserImage.jpg
Craig Rodrigues

Hello Mike , 
Yes you're right they are exactly the same. Validated this by adding a download button , and it seems to download the file perfectly. The issue lies upon displaying it. 

Upon further trying please use the ReactiveWebPreviewer component to view the file , it works. 

Also on a side note I have added another way in which compress a file using another component in case it's need. PFA , the oml.

I await your response in case anything else is needed.

Kind regards,
Craig


Mike_Testing_Reactive.oml
Community GuidelinesBe kind and respectful, give credit to the original source of content, and search for duplicates before posting.