动态获取文件的大小在亚马逊S3存储桶亚马逊、大小、文件、动态

由网友(说多了都是泪)分享简介:我已经看到了previous问题如何找到一个完整的S3桶的大小。这是有点不同的问题 - 所以我提前道歉,如果它是模糊的。我会尽我所能来解释我想实现的。I've seen previous questions on "How to find the size of an entire S3 bucket." This...

我已经看到了previous问题如何找到一个完整的S3桶的大小。这是有点不同的问题 - 所以我提前道歉,如果它是模糊的。我会尽我所能来解释我想实现的。

I've seen previous questions on "How to find the size of an entire S3 bucket." This is somewhat of a different question-- so I apologize in advance if it is vague. I'll do my best to explain what I am trying to achieve.

我目前使用亚马逊S3 PHP类

这就是我想实现的:

我希望能够遍历我的MySQL数据库和获取文件具体的文件名我S3服务器上。 (这可以基于用户)。

I would like to be able to loop through my MySQL database and get specific filenames of files on my S3 server. (This may be based on user).

在循环,查询亚马逊S3存储(不知),并获得那是在我的MySQL循环的每个文件的文件大小。

During the loop, query the Amazon S3 bucket (somehow) and get the filesize of each file that was in my MySQL loop.

添加了所有的filesizes,得到一个总的大概bytesize。

Add up all the filesizes, to get one total approximate bytesize.

因此​​,从本质上讲,让我们说我有对S3存储5个文件的用户。我怎么可能能够查询S3斗,看看有多少数据此用户的5个文件被存储在我的桶?

So, essentially, let's say I have a user that has 5 files on the S3 bucket. How might I be able to query the S3 bucket, to see how much data this user's 5 files is storing in my bucket?

我的道歉,如果这是很难理解的。我可以重新阐明,如果需要的话。

My apologies if this is difficult to understand. I can re-articulate, if needed.

任何的微调在正确的方向将是极大的AP preciated。

Any nudge in the right direction would be greatly appreciated.

推荐答案

您真的应该存储文件大小在你的MySQL表。更快地获得信息,少S3成本。

You really should be storing the filesize in your Mysql table. Faster to get the info, less S3 cost.

但...试试这个?

$info = $s3->getObjectInfo($bucketName, $filename);
print $info['size'];
阅读全文

相关推荐

最新文章