Methods of image storage

Asked

Viewed 1,889 times

7

I am studying what is the best way to store some images of users that are registered in my system.

I found 3 ways to solve this problem: Save to local directory, Save as BLOB and Save as Base64.

I would like to know the pros and cons of these options and which one would stand out from the others. And also if there’s any other way to save those images.

  • 3

    On the face, I can say that Base64 occupies 25% more space than the other 2 options and for storage it doesn’t make sense. For transmission, then it may be necessary depending on the medium used. (the details I leave to those who will post full reply).

  • 1

    In fact, the correct thing is for me to say that Base64 occupies 33% more than the original information. 25% is just the overhead contained in the coded information.

2 answers

1


Advantages of saving to a local directory: Does not use space from your bank of data, and yes of the very area of aramazenamento of the system, this makes storage be cheaper and be simpler if you need to save only the image, just create a storage structure as your needs.

Advantages of storage in Blob: If you have space to spare for database, this is a great method since you can add additional columns to saved image containing more information about them, it becomes easier to program because new programming languages bring tools that facilitate storage and is also easier to organize as they are entabeladas in a DB.

About storage in BASE64: Not recommended by increasing the size of the image at up to 25%, this method would be as an alternative to image transmission.

  • About local directory storage, this is 100% true, after a while, everything ends up getting too confusing. Renaming the image as id and everything else ends up being a complicated management if you have collections, "images within images" ex: real estate system, if you have the cover photo and the photos of the property, differentiate ends up being more complicated and messy.

  • Okay, one more question. If I have multiple images saved in a directory it is more feasible to pass these images to the Front end using Base64 or else I upload these images to the Front directly from the directory?

  • Base64 encoding is often used when there is a need to transfer and store binary data to a device designed to work with textual data. This encoding is widely used by applications in conjunction with the XML markup language, making it possible to store binary data in text form. I don’t think you have this extreme need to use Base64 to return your image. You need to hide the directory where the image is?

  • Since the system will stay on the local network I believe I do not need to hide the directory

1

My answer is based on the following answers from dozens found on SOEN 1 2 3

Local Directory

  1. Images can be easily cached when stored in the file system.

  2. Keeping images in DB is more expensive than keeping in a file system.

  3. In terms of performance it is probably best to store the file in the file system and only write the file name or file path and maybe mime type for database.

  4. Another reason to go for file system is when you have to share your data (images or sounds, video, whatever) with third party access: in the case web application that uses images that must be accessed from "outside" the local network in such a way that a database access to retrieve binary data is simply impossible.

  5. You will not have problems with increasing DB load and connections that consume (which can be expensive for database servers by licensed liaisons).

Database

  1. The reason for storing binaries (images) in a database is containment. When all data is in a database, this way greatly simplifies the backup strategy.

Browser other questions tagged

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