Skip to main content
WolfShade
Legend
September 26, 2017
Answered

Oracle db: Get file size from BLOB datatype

  • September 26, 2017
  • 1 reply
  • 1207 views

Hello, all,

I've got a table in an Oracle 12g db that is BLOB for storing files.  I'm trying to find a way to get the size of a single file contained within the BLOB column.

I am not saving the file to the server before inserting it into the db; it is going straight to the db to cut down on disk i/o, so I can't get the file size before inserting.

Any thoughts?

V/r,

^ _ ^

This topic has been closed for replies.
Correct answer WolfShade

Nevermind.  This has become a non-issue.  Given the lack of activity on the Adobe forums, and pressing time to get things done, I have been forced into a rather hackish way of getting the information I require.  I am posting the solution below.

I am now using JavaScript "files" API to include the filesize with the filename during upload, delimited by a pipe (|), and am using REGEXP_SUBSTR() in the select query to distinguish between the filename and size for display purposes.

I hate doing it this way, but don't have much choice as the project is launching on Monday.

V/r,

^ _ ^

var fileInput = document.getElementById('upload'), files = fileInput.files, fileName = files[0].size + "|" + files[0].name;

$('#fileName').val(fileName);

After upload:

SELECT REGEXP_SUBSTR(doc_name,'[^|]+',1,1) "DOC_SIZE", REGEXP_SUBSTR(doc_name,'[^|]+',1,2) "DOC_NAME"

FROM documents doc

1 reply

WolfShade
WolfShadeAuthorCorrect answer
Legend
September 27, 2017

Nevermind.  This has become a non-issue.  Given the lack of activity on the Adobe forums, and pressing time to get things done, I have been forced into a rather hackish way of getting the information I require.  I am posting the solution below.

I am now using JavaScript "files" API to include the filesize with the filename during upload, delimited by a pipe (|), and am using REGEXP_SUBSTR() in the select query to distinguish between the filename and size for display purposes.

I hate doing it this way, but don't have much choice as the project is launching on Monday.

V/r,

^ _ ^

var fileInput = document.getElementById('upload'), files = fileInput.files, fileName = files[0].size + "|" + files[0].name;

$('#fileName').val(fileName);

After upload:

SELECT REGEXP_SUBSTR(doc_name,'[^|]+',1,1) "DOC_SIZE", REGEXP_SUBSTR(doc_name,'[^|]+',1,2) "DOC_NAME"

FROM documents doc