Dynamic Switching Of Column based on Size

Odata Dev :

We are not sure what would be the size of file on upload an image

For now, planning to go with medium blob and using mysql as database.

Assume, if the customer uploads more than 16MB, the DB column should be automatically changed to longblob to accomodate the file. This is to cover the edge scenario, however we may not sure whether it would happen

What is the best way to support or achieve this?

Thanks.

maio290 :

The best way to achieve this is to define your database fields properly. You don't switch fields just because the file is larger than the datatype, that's bad design. Also, there are really no disadvantages from using a LONGBLOB from the start. If you want to limit the amount of data pasted into your database, you should already limit this in the java side, not rely on the database to do so.

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=169533&siteId=1