检查文件大小在S3上,无需下载?文件大小

由网友(谁把谁当真)分享简介:我已经上传到Amazon S3客户档案,我想加一个功能来计算这些文件为每个客户的大小。有没有一种方法来窥视到文件的大小,而无需下载呢?我知道你可以查看来自亚马逊的控制面板,但我需要做的吧亲语法。I have customer files uploaded to Amazon S3, and I would like...

我已经上传到Amazon S3客户档案,我想加一个功能来计算这些文件为每个客户的大小。有没有一种方法来窥视到文件的大小,而无需下载呢?我知道你可以查看来自亚马逊的控制面板,但我需要做的吧亲语法。

I have customer files uploaded to Amazon S3, and I would like to add a feature to count the size of those files for each customer. Is there a way to "peek" into the file size without downloading them? I know you can view from the Amazon control panel but I need to do it pro grammatically.

推荐答案

发送一个HTTP HEAD 请求的对象。 HEAD请求将获得相同的HTTP标头的GET请求,但不会检索对象的主体(节省您的带宽)。然后,您可以解析出从HTTP响应头中的Content-Length头值。

Send an HTTP HEAD request to the object. A HEAD request will retrieve the same HTTP headers as a GET request, but it will not retrieve the body of the object (saving you bandwidth). You can then parse out the Content-Length header value from the HTTP response headers.

阅读全文

相关推荐

最新文章