WT86 WT86 - 4 years ago 155
SQL Question

Get File Size of stored files and new uploaded ones

I have a web app that is connected to a mySQL DB in BLOB Format, and there are some files stored in the DB, how can I fetch their sizes and add them to a new column in the table I'm using ? And what is the best approach to get file size of an uploaded file in JAVA ?!

Answer Source

For your new records that will be processed in Java you can use File.length() if you're working with a File object.

And for existing records, you can use OCTET_LENGTH(your_column_name) statement (source: Calculating total data size of BLOB column in a table) which will give you the size in bytes.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download