Treatment of Python Images

Asked

Viewed 332 times

3

I have a question here of architecture:

The application we are building has a load of images pro system. They are photos of ads, and each one can upload 12 photos. These ads are dynamic, meaning they may be available today and tomorrow no more. By researching a lot, I checked two ways to do:

  1. save the images to a local folder on the server and in the database to save only the image path. This would save a lot of space, but would make it difficult to control things, because we would have to have a rule to delete images as ads are removed. But a 900k image would have on the 900k server really. The backup would also be more complicated.

  2. convert the images into Base64 string and record straight into the bank, which would facilitate maintenance, but in test I made the image that has 900k was with 3,88M in the base. So since there would be a lot of images, I’m afraid the server will scale too fast and we will be at a very high cost.

I did not succeed recording as Bytea.

I’m using Python 3, Django 2 and Postgressql.

If anyone has a more assertive suggestion it would be helpful.

  • 3

    I would recommend using a cloud service such as an AWS or Cloudflare etc

  • @carlosgaddini, yes very well commented. Every application runs on an AWS. Thanks for the tip.

2 answers

0

Following the line suggested in the comment of the colleague @carlosgadinni, the use of a service of Cloud Storage could be a very versatile solution and scalable for your problem.

Cloud storage service providers almost always provide a API Web for data manipulation, making it possible to read, write and query your images directly in the cloud, which would greatly facilitate the integration of your system with the amazement service.

Your database would store only one identifier or image URL, delegating all the complexity of image storage to the service only.

  • @lLacobus any suggestions for hiring in this case? In your example I would have the image stored outside of my server and would search a service url, correct?

0

I would recommend saving in a directory 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.

  • Show ball Luis Eduardo. I really thought the way would be better around. Thanks for the tip.

  • 1

    This will get expensive heim! better pay attention to the comment of @carlosgaddini asked in the question.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.