GET Bucket (List Objects)

  • 描述:获取bucket下所有object。

  • 请求格式:

GET /?formatter=json HTTP/1.1
Host: <Your-Bucket-Name>.ss.bscstorage.com
Date: <date>
Authorization: <authorization string> #请参照《签名算法》

或者

GET /<Your-Bucket-Name>/?formatter=json HTTP/1.1
Host: ss.bscstorage.com
Date: <date>
Authorization: <authorization string> #请参照《签名算法》
  • 请求参数:
Parameter Description Required
delimiter 折叠显示字符。通常使用:‘/’ No
marker Key的初始位置,系统将列出比Key大的值,通常用作‘分页’的场景 No
max-keys 返回值的最大Key的数量。默认为400 No
prefix 列出以指定字符为开头的Key No

响应格式举例(HTTP Body):

{

    Delimiter: "/",

    Prefix: "html/",

    CommonPrefixes: [

        {
            Prefix: "html/assets/"
        },

        {
            Prefix: "html/attributions/"
        },

        {
            Prefix: "html/documentation/"
        },

        ...
    ],

    Marker: null,

    ContentsQuantity: 5,

    CommonPrefixesQuantity: 3,

    NextMarker: null,

    IsTruncated: false,

    Contents: [

        {
            SHA1: "9fc710aa89efbe42020b0310d16a07449bf06131",
            Name: "html/coming-soon.html",
            Expiration-Time: null,
            Last-Modified: "Fri, 21 Mar 2014 01:50:46 UTC",
            Owner: "Baishan0000000000000001",
            MD5: "934d922cac80449ee361cefeb3276b3e",
            Content-Type: "text/html",
            Size: 8781
        },

        {
            SHA1: "a9625a128263f05e331f6d78add9bd15911c3565",
            Name: "html/ebook.html",
            Expiration-Time: null,
            Last-Modified: "Fri, 21 Mar 2014 01:50:47 UTC",
            Owner: "Baishan0000000000000001",
            MD5: "cb7ed943ead4aeb513aa8c0b76865a8b",
            Content-Type: "text/html",
            Size: 18734
        },

        ...
    ]
}
  • 返回值说明:
Name Description
Contents Object的Metadata数组
CommonPrefixes 折叠以后的Prefix,下一级是Prefix数组
Delimiter 当前使用的折叠字符
Prefix 当前使用的前缀
Marker 当前使用的Marker
ContentsQuantity Contents中元素个数
CommonPrefixesQuantity CommonPrefixes中元素个数
NextMarker 下一页的Marker
IsTruncated 是否还有下一页
SHA1 文件内容的sha1值
Name Object的Key(文件名)
Last-Modified Object的最后修改时间
Owner Object的拥有者
MD5 文件内容的md5值
Content-Type 文件的mime type
Size 文件的大小(字节)
  • 应用举例: 假设某Bucket下有如下文件(为方便说明,没有显示为json格式,仅表现其中的一些有用信息,以下同):
join/mailaddresss.txt
join/mycodelist.txt
join/personalfiles/connects.docx
join/personalfiles/myphoto.jpg
join/readme.txt
join/userlist.txt
join/zero.txt
mary/personalfiles/mary.jpg
mary/readme.txt
sai/readme.txt

使用prefix指定以join/为开头的文件:

GET /?prefix=join/&formatter=json HTTP/1.1
Host: <Your-Bucket-Name>.ss.bscstorage.com
Date: <date>
Authorization: <authorization string> #请参照《签名算法》

返回:

Contents:
    join/mailaddresss.txt
    join/mycodelist.txt
    join/personalfiles/connects.docx
    join/personalfiles/myphoto.jpg
    join/readme.txt
    join/userlist.txt
    join/zero.txt

使用delimiter指定折叠方式为‘/’:

GET /?delimiter=/&formatter=json HTTP/1.1
Host: <Your-Bucket-Name>.ss.bscstorage.com
Date: <date>
Authorization: <authorization string> #请参照《签名算法》

返回:

Contents:

CommonPrefix:
    join
    mary
    sai

使用prefix指定以join/为开头的文件,同时使用delimiter指定折叠方式为‘/’:

GET /?prefix=join/&delimiter=/&formatter=json HTTP/1.1
Host: <Your-Bucket-Name>.ss.bscstorage.com
Date: <date>
Authorization: <authorization string> #请参照《签名算法》

返回:

Contents:
    join/mailaddresss.txt
    join/mycodelist.txt
    join/readme.txt
    join/userlist.txt
    join/zero.txt
CommonPrefix:
    join/personalfiles/

使用max-keys做最大值列表长度限制:

GET /?prefix=join/&delimiter=/&max-keys=4&formatter=json HTTP/1.1
Host: <Your-Bucket-Name>.ss.bscstorage.com
Date: <date>
Authorization: <authorization string> #请参照《签名算法》

返回:

IsTruncated : true
Next-Marker : join/userlist.txt
Contents:
    join/mailaddresss.txt
    join/mycodelist.txt
    join/readme.txt
CommonPrefix:
    join/personalfiles/

使用marker继续获得之前的列操作的后续结果:

GET /?prefix=join/&delimiter=/&max-keys=4&marker=join/userlist.txt&formatter=json HTTP/1.1
Host: <Your-Bucket-Name>.ss.bscstorage.com
Date: <date>
Authorization: <authorization string> #请参照《签名算法》

返回:

IsTruncated : false
Contents:
    join/userlist.txt
    join/zero.txt

results matching ""

    No results matching ""