检查文件大小在S3上,无需下载? [英] Check file size on S3 without downloading?

查看:288
本文介绍了检查文件大小在S3上,无需下载?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经上传到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.

这篇关于检查文件大小在S3上,无需下载?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆