Discussions
Categories
Groups
Community Home
Categories
INTERNAL ENABLEMENT
POPULAR
PUBLIC CLOUD
PRIVATE CLOUD
Quick Links
MY LINKS
HELPFUL TIPS
Back to website
Home
Web CMS (TeamSite)
Mediabin Java - Asset Size
shivram13
Hello,
I would like to get the total size of a container which includes the filesize of all the assets in that container and its child-containers.
I have two objects MediaBinServer and MediaBinServerSoap already but I can not find then appropriate method to get the total file size.
I tried this but as the root container does not have any direct assets in it, it returned 0.
MBAsset[] assets = mMediaBinServer.getAssetList(mMediaBinServer.getRootContainer().getMID());
System.out.println("Asset count:"+assets.length);
Can any one help me how to recursively go through all the assets in that container and its child containers and get the total size of all the assets?
If possible, could any one provide me the snippet to handle the same or direct me if I can find any sample files somewhere?
Thanks
Shivram Rajamanickam
Find more posts tagged with
Comments
lyman
This is going to be an expensive piece of information. Each asset has a piece of metadata that gives its size (prior to 4.6 this was in bytes and from 4.6 on in kbytes). You would need to recurse.
How often is this needed and how often do files get added to your MediaBin? We also have the ability to assign metadata to folders and it might be useful to make a custom metadata field "total size" and use this as an ad hoc "cache" for this information updating as files are added.
Cheers,
Lyman Hurd
shivram13
Hi Lyman,
Thanks for your reply.
There are more users actively be using Mediabin and the files or its details may change more often and dynamic.
I have looked at the Asset object and found that it has the method to get its file size. But, how can I get all the assets from a particular container which should include all the assets under its subcontainers too?
Could you or anyone please suggest me any solution for this?
Thanks
Shivram
lyman
There's no direct way. You would need to write a loop that gets assets in this container and then gets all subcontainers and recurses!
Given some typical directory structures I hope you understand that a method that simultaneously returned all descendants of a directory would have significant unintended consequences! For some customers that could represnt millions of returns.
Cheers,
Lyman Hurd