Length property of Media objects saved in tables

I store a media object in a table.
During “storage” phase, I can read the size of the media object.
Oddily, when I read the media object back, the .length property returns None.

Here’s a small app showing the issue.
Just upload a file and refresh.
Sizes computed at save-time are there, sizes computed at read-time are None


It certainly seems like that should work better. As a workaround, you can get the length of the bytes at runtime:


I agree with @jshaffstall, I wouldn’t expect an actual file to return a length of None. Seems like a bug.

As another workaround, save the length as the value of an adjacent database table column, in the same row, when the media object is saved. Once you do that, then you don’t have to actually retrieve the media object contents (which may be an extra round trip to the database) just to get the length.

1 Like

Hello @aldo.ercolani,

Thanks for raising this. I’ve added it to our list.

1 Like

Any update on this issue? I ran it to it today.

Issue is still here.
works fine.