Context: FM12, external container data
Files fields: clientID (text), file (container, external storage), filename (text, autoenter calc using custom function), filesize (number, autoenter calc using custom function)
I'm using a custom function 'containerInfo' to extract the file info thus;
// FilenameContainer ( ContainerAsText )
// Returns a FileMaker Container Field Filename.
// Hal Gumbert, Campsoftware.com
// Modified by Steve Winter, Matatiro Solutions
theTextInfo = ContainerAsText ;
filenameLocal = GetValue ( theTextInfo ; 1 ) ;
remote = RemoveEmptyValues ( FindValues ( theTextInfo ; "remote:" ; False ) ) ;
filenameRemote = Substitute ( remote ; "remote:" ; "" ) ;
file = If ( IsEmpty(filenameRemote); filenameLocal; filenameRemote);
size = GetAsNumber(Substitute( RemoveEmptyValues ( FindValues ( theTextInfo ; "size:" ; False ) ) ; "size:"; ""));
dpi = Substitute( RemoveEmptyValues ( FindValues ( theTextInfo ; "dpi:" ; False ) ) ; "dpi"; "");
paths = RemoveEmptyValues ( Substitute ( theTextInfo ; [ remote ; "" ]; [ size ; "" ]; [ dpi ; "" ]));
response = Case(dataReq = "filename"; file; Case(dataReq = "size"; size; Case(dataReq = "dpi"; dpi; Case(dataReq = "paths"; paths; ""))))
This is, as you'll see a modified version of a custom function from Hal Gumbert (thanks Hal :-) which I use thus
$name = containerInfo(GetAsText(file); filename)
$size = containerInfo(GetAsText(file); size)
This works really well for the filename, but I'm getting totally screwy numbers back for the filesize - a 7.5mb pdf returns 612792, yet a 120kb image returns 997355.
I assume that this is because what I'm actually geting size info about is the metadata about the file which is stored in the db, and not actually about the file itself...
So, does anyone know a way to reliably get the size of a file which is added via drag-and-drop into an externally-stored container...?