Technology Blog Posts by SAP
cancel
Showing results forΒ 
Search instead forΒ 
Did you mean:Β 
Yogananda
Product and Topic Expert
Product and Topic Expert
2,049

Storing and Retrieving Files in SAP HANA Cloud as BLOB

StockCake-Overwhelmed with paperwork_1737191038.jpg

Background

In today's complex & heterogeneous landscape, efficient data storage and retrieval are crucial for businesses. SAP HANA Cloud offers robust capabilities for handling large volumes of data, including Binary Large Objects (BLOBs). This blog will guide you through the process of storing and retrieving files in SAP HANA Cloud using BLOBs.

What is a BLOB?

A BLOB (Binary Large Object) is a collection of binary data stored as a single entity in a database management system. BLOBs are typically used to store multimedia files such as images, videos, and documents.

Setting Up Your Environment

Before you begin, ensure you have the following:

  • Go to BTP Trail or Global Account
  • Go to HANA Cloud
  • Create table from sql
  • Clone the github repo to your local drive
  • Update the credentials from BTP - HANA Service Key
  • Update the file path for uploading to HANA Cloud
  • Update the file path for downloading to local drive from HANA Cloud Table

In your BTP Subaccount - Create Instance for HANA Schema & HDI Containers and Create a Service Key to access HANA Cloud
2025-01-18_09-51-30.png

Creating a BLOB File Storage Table

This command creates a table with columns for the file ID, file name, file type, file content and upload date. The sequence ensures unique IDs for each file.

 

 

 

CREATE TABLE FILE_STORAGE (
    FILE_ID INTEGER GENERATED ALWAYS AS IDENTITY PRIMARY KEY,
    FILE_NAME NVARCHAR(256),
    FILE_TYPE NVARCHAR(100),
    FILE_SIZE INTEGER,
    FILE_CONTENT BLOB,
    UPLOAD_DATE TIMESTAMP DEFAULT CURRENT_TIMESTAMP
)

 

 

 

Clone from Github repo

source code : https://github.com/yogananda-muthaiah/HANA-Cloud-Blob-Store

2025-01-18_10-31-54.gif

Preview in your SQL Console to check all the files are stored as BLOB type with file size

2025-01-18_09-54-58.png

Conclusion

Storing and retrieving files as BLOBs in SAP HANA Cloud is a powerful feature that allows you to manage large binary data efficiently. By following the steps outlined in this blog, you can set up a robust system for handling file storage and retrieval in your SAP HANA Cloud environment.