简体   繁体   English

访问cloudfiles对象的大小?

[英]Accessing the size of a cloudfiles object?

Is it possible to grab the size of a cloudfiles object without retrieving the whole object? 是否可以在不检索整个对象的情况下获取cloudfiles对象的大小?

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. 我有500,000个文件,我想知道它的字节大小,但如果我在每个文件上请求整个对象,它将花费我100美元的带宽费用。

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. 谢谢,并帮助赞赏。

Using the PHP SDK, you have a couple of options: 使用PHP SDK,您有几个选择:

  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. 如果要查找每个文件的大小,可以先检索容器中的文件列表,然后循环遍历它们,在循环中的每个文件上调用getContentLength()方法。

  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 . 如果您正在查找所有500,000个文件占用的总大小,您可以简单地获取它们所在容器的大小。以下是代码: https//github.com/rackspace/php -opencloud / blob / master / docs / userguide / ObjectStore / USERGUIDE.md#get-bytes-used

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM