This app is an All-In-One package to provide everything to HANA Lovers.
1. Courses on SAP HANA - Basics, Modeling and Administration
2. Multiple Quizzes on Overview, Modelling, Architeture, and Administration
3. Most popular articles on SAP HANA
4. Series of Interview questions to brushup your HANA skills
How image is saved in HANA database in BLOB format
How to upload image in SAP HANA
How to download image from HANA and show in HTML
What is a BLOB?
BLOB (Binary Large Object) is a field type for storing Binary Data.
BLOB could store a large chunk of data, document types and even media files like audio or video files. In HANA the BLOB size can be up to 2 GB.
In HANA database, we can use BLOB data type to store image.
Create Image Table:
Let’s first create a table in HANA to store images.
Copy and paste below script to create table.
--REPLACE <SCHEMA_NAME> WITH YOUR SCHEMA NAME
CREATE COLUMN TABLE "<SCHEMA_NAME>"."IMAGE_STORE"(
IMAGE_NAME NVARCHAR(20) PRIMARY KEY,
Download some sample images:
Download some sample images and save in a folder.
For this example I downloaded some images of SAP HANA and saved in “C:\ImageToBeUploaded”
Upload images into HANA database:
There are several ways of uploading images into HANA database. For example: Java, Python etc.
Here we will use Java program to upload image. Note: You can either use a different eclipse tool for java or use the same HANA Studio to create a Java project. If you are using HANA Studio, then make sure you have selected “SAP HANA Development” perspective.
Open JAVA Eclipse (or HANA Studio) and create a Java project called "ImageUploader".
Go to File --> Import --> General and select "Archive File".
Click on browse and select the " ImageUploader.zip " file you downloaded in step 1. Click on finish.
Open ImageUploader.java file and change the HANA system details.
Run the Java program. You should see similar message in console.
We have successfully uploaded the image files into HANA database.
Have the images really uploaded to HANA?
You might be wondering that have the files really uploaded to HANA. Let us check that.
Open HANA studio and open SQL console. Check the output of IMAGE_STORE table.
SELECT * FROM "<SCHEMA_NAME>"."IMAGE_STORE";
The output shows that image files are uploaded in BLOB format.
Download image from SAP HANA:
We need to create a HANA XS project to download the image from HANA.
Create a HANA XS project.
Download the zip file and extract it somewhere in your local system.
Copy all the content inside “ImageProcessing” folder.
Go to HANA Studio and paste everything inside
Open GetImage.xsjs file and change the YOUR_SCHEMA_NAME in first line to your schema name. Make sure it is the same schema where you created the “IMAGE_STORE” table.
Right click on the project and select Team --> Activate.
Now let us test this.
Open ImageBrowser.html file under “ui” folder. Right click and select Run As --> HTML
Search for the image that you uploaded. If the image is found it will display the image.
You can search with the name of the images you uploaded.
If you have any question or doubt, please leave a comment or contact us.