Storing and retrieving pdf files in MySQL DB from Retool App

Hello,

My use case requires that I store a small PDF file in a MySQL record. I use the filebutton to get the file and am able to store it in the database in a blob column. When I look at the data in the db it looks like the base64 data the filebutton created and my update pushed to the DB.

My challenge arises when I am trying to display it in the pdf component.

  • I am retrieving the rows into a table hiding the column containing the base64 data.
  • I attached an edit form to the table and when a user clicks edit the selected row populates the form.
  • I am struggling to find the proper syntax to display the PDF content that I stored in the DB to render in the PDF component on the edit form.

This is how I am doing it now and its not working. The base64 data is in my column named pdf.

Any help would be greatly appreciated.

Thanks!!

Bernard

Solved this myself. I needed to change the datatype in the MySQL Database to text vs blob. Everything works fine. The retool filebutton is automatically encoding for you so no need to encode it again as a binary large object in the database. You can store the base64 encoded string directly into a text field. This is just for a specific use case. We generally use file storage for storing associated files.