Does anyone know a way to get the size of attachment in bytes into a BAQ? I can’t find anywhere in the database that stores this. We are using ECM for our main storage type.
I do not think this is stored anywhere in Db, or available in BO call that I know of.
The closest place I can think of that would have it is Ice.BO.AttachmentSvc.DocStarGetMetaData(xFileRefNum, "", "", "")
But that dataset doesn’t return filesize info either.
The only way I can think of to get it is to create a byte[] = Ice.BO.AttachmentSvc.DocStarDownloadFile(xFileRefNum);
And output the size of that, but obviously horridly impractical.
Maybe the best way is to create a UD field for filesize on XFileRef table, and put a pre bpm on upload BO to store filesize there.
Damn. I also tried out the DocStarGetMetaData endpoint with no luck.
I was thinking the UD route could be possible. I would have to create a function to backload the data.
please do not download each attachment to calculate their sizes. that is too much even for you ![]()
Perhaps one of the ideas of all time, using REST and the ECM API to get the data:
Call the ECM endpoint -
http://{ECMServer}/{ECMPath}/HostingV2/User.svc/rest/LogIn
Method: POST
Pass headers: content-type: application/json
Pass body:
{
"Password":"{ECMPassword}",
"ProxyLogin": false,
"ProxyOnBehalfOf": "00000000-0000-0000-0000-000000000000",
"Username":"{ECMUsername}"
}
Receive {token}
Call the ECM endpoint -
http://{ECMServer}/{ECMPath}/AstriaV2/Document.svc/rest/Get
Method: POST
Pass headers: content-type: application/json
ds-token: {token}
Pass body: "{FileGuid}"
Receive json object
Get Result.ContentItems.Length value
Wonder if it was worth it
It worked with a couple files of ours. If you have a similar setup, and this doesn’t sound awful, hopefully it could work for you.