在不下载的情况下检查 S3 上的文件大小? [英] Check file size on S3 without downloading?

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

问题描述

我已将客户文件上传到 Amazon S3,我想添加一项功能来计算每个客户的这些文件的大小.有没有办法窥视"文件大小而不下载它们?我知道您可以从 Amazon 控制面板查看,但我需要以编程方式进行.

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 请求将检索与 GET 请求相同的 HTTP 标头,但不会检索对象的主体(节省带宽).然后,您可以从 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天全站免登陆