0

I am currently working on an Angular application, a POS system for a hardware store, that uses a AWS Aurora PostgreSQL database as the backend and a Nodejs API hosted on AWS API Gateway. Is there a way I can store images of the products onto the database and retrieve them using the APIs so that I can display them in my project?

Nooh Ahamad
  • 353
  • 10
  • 23
  • 2
    Of course this is possible but we need much more information to help you. There are [posts](https://stackoverflow.com/questions/13124711/storing-a-file-in-postgres-using-node-postgres) that can guide you to get started. Let us know where you get stuck. – stdunbar Jan 26 '21 at 17:17

1 Answers1

2

You can store images in databases like PostgreSQL using the datatype like bytea. But it's not an optimal way of storing files like images. The best way is to store the files like images, videos, etc in the storage like Amazon S3.

You have to store the images in the storage like S3 in the case of AWS and store the URL of the images stored in the S3 to the AWS Aurora PostgreSQL database. After that, you can fetch the images into your project using the AWS Aurora PostgreSQL database.

Or, after storing the images in the S3, you can directly use the images in your project because S3 provides the URL to the files stored in it.

Ankush Chavan
  • 1,043
  • 1
  • 6
  • 20
  • While in many situations this is true it doesn't answer the question. There are good reasons why storing images to DB might actually be a better solution. Most importantly it ensures consistency between database and image files. – Marek Fajkus Feb 26 '23 at 19:02