Question

Is it possible to grab the size of a cloudfiles object without retrieving the whole object?

I have 500,000 files that I want to know the byte size of, but if I request the whole object on each one it will cost me $100 in bandwidth charges.

I know I can get a list of objects in a container, but that only seems to give me the name of the objects?

Thanks, and help appreciated.

Was it helpful?

Solution

Using the PHP SDK, you have a couple of options:

  1. If you are looking for the size of each file, you can retrieve the list of files in a container first, then loop over them, call the getContentLength() method on each file in the loop.

  2. If you are looking for the total size taken up by all your 500,000 files, you can simply get the size of the container(s) they are in. Here is the code for that: https://github.com/rackspace/php-opencloud/blob/master/docs/userguide/ObjectStore/USERGUIDE.md#get-bytes-used.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top