I have a question here about architecture:
The application we are building has a load of images for the system. These are ad photos, and each one can upload 12 photos. These ads are dynamic, meaning they may be available today and no longer tomorrow. Searching a lot, I found two ways to do it:
save the images in a local folder on the server and in the database save only the path of the image. This would save a lot of space, but it would make it difficult to control things, as we would have to have a rule to delete the images as the ads are being removed. However a 900k image would have 900k on the server actually. Backup would also be more complicated.
convert the images into string base64 and record directly in the database, which would facilitate maintenance, but in a test I did the image that has 900k, which was left with 3.88M in the base. So, as there would be many images, I'm afraid the server will scale too fast and we will have a very high cost.
I wasn't successful recording as ByteA.
I'm using Python 3, Django 2 and PostgresSQL.
If anyone has a more assertive suggestion it would be of great help.
I would recommend saving to a directory rather than directly inside the database as a blob. Each ad has a folder in that directory with the images inside this folder, if the ad is removed, just remove the folder with the images inside.