GetObject

更新时间:2025-08-18 15:52:04

对象所在空间所属用户可以执行GET操作,返回信息包括对象内容和对象的元数据信息。

请求语法

GET /ObjectName?response-cache-control=ResponseCacheControl&response-content-disposition=ResponseContentDisposition&response-content-encoding=ResponseContentEncoding&response-content-language=ResponseContentLanguage&response-content-type=ResponseContentType&response-expires=ResponseExpires HTTP/1.1
 
Host: Bucket.Endpoint
Date: date
Authorization: authorization
 

URI请求参数

在获取对象时,可以通过请求参数重写响应头。可重写的响应头包括:Content-TypeExpiresContent-languageCache-ControlContent-DispositionContent-Encoding

参数 描述 是否必填
response-content-type 重写响应中的 Content-Type 头。
不同的 Content-Type 会导致用户看到不同效果。默认 text/html,即网页形式。例如:text/html;charset=utf-8
类型:String。
response-expires 重写响应中的 Expires 头,表示浏览器缓存过期时间。
类型:String。
response-content-language 重写响应中的 Content-Language 头。
类型:String。
response-cache-control 重写响应中的 Cache-Control 头,用于控制网页缓存。常见值有 private、no-cache、max-age、must-revalidate 等,默认 private。
类型:String。
response-content-disposition 重写响应中的 Content-Disposition 头,当用户将内容保存为文件时,提供默认文件名。例如:attachment; filename="cool.html"
类型:String。
response-content-encoding 重写响应中的 Content-Encoding 头。例如:gzip, deflate。
类型:String。

请求头

公共请求头外,还包含:

参数 描述 是否必填
If-Match 如果对象的ETag与请求中的ETag一致,返回对象内容,否则返回412(precondition failed)(not found)。
类型:string。(ETag值,例如:0f64741bf7cb1089e988e4585d0d3434)
If-Modified-Since 如果对象的修改时间晚于该值,返回对象内容,否则返回304(not modified)。
类型:string。
If-Unmodified-Since 如果对象的修改时间早于该值,返回对象内容,否则返回412(precondition failed)。
类型:string。
If-None-Match 如果对象的ETag与请求头指定的ETag不一致,则返回对象内容,否则返回304(not modified)。
类型:string。
Range 获取对象指定范围内容。如果Range不符合要求,则返回416 Requested Range Not Satisfiable。Range的最小起始值为0,最大为对象长度减1。
类型:string。(例:bytes=0-4 或 bytes=512-1024)

请求体

响应语法

HTTP/1.1 status_code
 
x-wos-request-id: request id
Content-Type: type
Date: date
Content-Length: length
Etag: etag
Last-Modified: time
<Object Content>
 

响应头

公共请求头外,还包括如下头部:

名称 描述
Etag 上传数据的Entity tag
x-wos-storage-class 指定文件的存储类型,Standard-标准存储、IA-低频存储、Archive-归档存储。默认为该空间的存储类型
x-amz-meta-* 自定义元数据

:如果您访问的是静态文件(包含htm、html、jsp、plg、htx、stm格式的文件),会额外响应Content-Disposition: attachment头让浏览器执行下载操作。如您需要让浏览器预览此类文件,可到空间管理中绑定您的自定义域名,使用自定义域名访问不会额外添加Content-Disposition: attachment

响应体

示例

GET /test HTTP/1.1
User-Agent: Jakarta Commons-HttpClient/1
Host: bucket.s3-cn-east-1.wcsapi.com
Accept: */*
Date: Sat, 03 Dec 2011 08:28:02 +0000
Authorization: AWS BF6C09F302931425E9A7:tQ+A280jUgPCAdSTuUis35T9gWI=
 
 
HTTP/1.1 200 OK
 
x-wos-request-id: 001B21A61C6C0000013403098535528C
x-wos-storage-class: Standard
ETag: "507e3fff69b69bf57d303e807448560b"
Last-Modified: Sat, 03 Dec 2011 08:25:46 GMT
Accept-Ranges: bytes
Content-Length: 30
Content-Type: binary/octet-stream
Date: Sat, 03 Dec 2011 08:28:02 GMT
 
[30 bytes of object data]
 
本篇文档内容对您是否有帮助?
有帮助
我要反馈
提交成功!非常感谢您的反馈,我们会继续努力做到更好!