0

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 ?!

WT86
  • 823
  • 5
  • 13
  • 34

2 Answers2

1

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.

Community
  • 1
  • 1
Gaël J
  • 11,274
  • 4
  • 17
  • 32
0

select file_name, Octet_length(blob_colume) as "Size in Bytes" from Table_name;