Jump to content
Claris Engage 2025 - March 25-26 Austin Texas ×
The Claris Museum: The Vault of FileMaker Antiquities at Claris Engage 2025! ×

This topic is 6505 days old. Please don't post here. Open a new topic instead.

Recommended Posts

Posted

Is it possible to get the filesize for a file stored in a container field so it can be inserted into another field? From what I can tell FileMaker's "get(filesize)" function only gets the size of the entire database and there's no way to tell it you just want the size of a file stored in a particular record.

Thanks!

Helo

Posted

Since you're on a mac, could you use an applescript to do it? Or will your database be used by Windows machines too?

Posted

Try using the length() function on the container -- should work if your actually storing the file within the container field and not just referencing it.

Posted

Hey, thanks! That's exactly what I was looking for. Except now I have another problem. The number inserted into the field is HUGE. The number of bytes is vastly larger than the actual file size. I thought maybe it was tacking on some extra size from the whole record or from the database, but the amount of extra bytes added to the apparent file size isn't consistent from one file to another.

Any ideas?

Helo

Posted

Just to make sure... it returns bytes, not KB....

So use ( Length( containerField ) / 1024 ) / 1024 -- to return MB or ( Length( containerField ) / 1024 ) to return KB

If it really is bloated, give comparison figures... (i.e. OS size vs Container Size) and what are you storing, PDF's, images, docs etc.

Posted (edited)

Yep, I know length(container field) is supposed to give the size of the file in bytes. I loaded a .png file into the container field and the file size was calculated to be 2,369,955 byes. However, my Mac says the the file is only 338,903 bytes. Another .png file is calculated in FileMaker to be 837,012 bytes, but my Mac says the file is 114,572 bytes. And so it is with all the other files, which are mostly .png, .jpg, and .pdf.

I had set up a button using the "insert picture" script instead of the "insert file" function to populate my container field. I did this because all of my files are maps and I need to have a preview available for each record. The "insert file" script previews only the icon, while the "insert picture" script previews the actual document. I have another button to "export file" and it seems to export the original file, regardless of whether it was inserted using the "file" or "picture" method.

I just discovered, however, that if the file is inserted as a "picture" rather than as a "file" it gives me the hugely inflated byte count. When I insert the map as "file" it accurately calculates the byte count. Of course in that case I then don't get a preview of the actual file, just its icon.

This makes no sense to me. Why in the world can you have one or the other, but not both? Why does a "file" have no real preview, while a "picture" has no correct file size? Why does FileMaker even distinguish between a "file" and a "picture?" Why can't it accurately calculate a file size using two virtually identical methods of loading?

--

Helo

Edited by Guest
Posted

Are you using Copy/Paste to get these pictures in? It is not the preferred method, and produces these kind of differences (it looks like the original is being converted to PICT or TIFF). When I use FileMaker's Insert Picture command, the file is only 2-4K bigger than the inserted image.

Posted

I vaguely remember somewhere reading that when updating a fm6 file to fm7 that contained images the filesize would be greatly inflated. It was something to do with container fields now storing image data for both platforms.

Sorry that i am unable to find the source.

  • 3 weeks later...
Posted (edited)

I may be off base here, but does length return bytes, or bits? If bits (1/8 of a byte), your numbers come out about right.

Edited by Guest
Posted

Well I don't know, i haven't really had to calculate it before, but the FM help manual has this to say:

LENGTH FUNCTION

Format

Length(field)

Parameter

field - any text, number, date, time, timestamp, or container field, or any text expression or numeric expression

Data type returned

number

Description

Returns the number of characters in field, including all spaces, numbers, and special characters. For a container field, Length returns the total stored size of objects in bytes.

Posted

Yeah I read that. When I import the files as "picture" the numbers are way off. I've tried converting them in various ways to see if I could figure out if they're just in some other units but they aren't in any units I've been able to work out. Again, when I import the file as "file" the units are deadly accurate. It doesn't make sense to me.

Posted

I think that it has to store it in various different formats for both platforms and maybe also IWP?...

Or how much larger is the image?... i.e. possibly 33% larger?

This topic is 6505 days old. Please don't post here. Open a new topic instead.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.