Storing images as Base64 encoded string in DB - Allowed?

Website URL

I’m not getting DDoSed again.

Error Message

N/A

Other Information

I know that storing images as a “File sharing” thing isn’t allowed, but does it apply to all forms of images, uploaded to server and uploaded to DB with Base64 encoding?

I’m working on adding Image Support for my project, and I don’t want to have any troubles.

1 Like

It depends on what you plan to use the upload feature for. If it’s for a purpose not directly related to file sharing (like profile photos) it should be OK.

But there’re also no need to store them in the database as base64. Databases have a much smaller storage limit, and doing also consumes way more resource than just loading a file, which means that you are more likely to hit a database limit if you store images in this way.

5 Likes

Sharing images via a certain mail protocol that starts with the beginning of my username to other users.

I wasn’t aware of a DB storage limit. What is the limit?

I didn’t want to “waste” hits loading images.

I’m not Admin, but this sounds like a form of file sharing to me. Even if the images are encoded as base64 to be distributed, they’re still being shared.

5 Likes

It’s just a few hundred MB I think, something like around 300-800 MB but don’t quote me on this. But whatever the limit is it’s much smaller than the disk limit.

A long time ago a person comes up with am exact same idea like this. I cannot remember what is that topic but Admin did some calculations and it’s totally not worth it.

4 Likes

My interpretation of the rules is that images you host should be viewable by many people, and the sharing of such files is not the main purpose of your site. In my opinion, a private image sharing service (essentially what you are proposing), is not allowed. I would recommend you use Amazon S3 for this.

edit: also, don’t use base64 if your putting images in a database, store the image binary instead (it’s much smaller)

7 Likes

Image sharing sites are not allowed. That’s the rule. The rule doesn’t say anything about specific methods of how that image sharing site works.

While there is no fixed limit on database space used as far as I am aware, fair usage limits apply, and if we find out that the database server is being filled by you thinking you found a free way to get unlimited storage, we’re going to take actions that you may not like.

And storing files in a database is an objectively very inefficient way to handle uploaded files. Serving a file directly from storage is very inefficient, but firing up a PHP script that opens a network connection to retrieve a file from a database server is much slower, and may cause you to run into other account limits.

And storing them as base64 encoded text is also a very inefficient way to do it. MySQL can just store binary data as BINARY, VARBINARY or BLOB data types (analogous to CHAR, VARCHAR and TEXT for textual data). By adding base64 encoding you’re just wasting disk space and CPU cycles.

9 Likes

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.