1.28.19 list-objects

优质
小牛编辑
121浏览
2023-12-01

List objects related api supported by FDS

Version: 1.0.0

/{bucketname}

GET

Summary:

获取某个Bucket下的Object列表

Description:

需要有Bucket的READ权限,返回的结果可能被分页,需要多次调用才能获取完整列表;服务端将Object按名字的字典返回给客户端

Parameters
NameLocated inDescriptionRequiredSchema
bucketnamepathbucket名字Yesstring
prefixquery需要列出的Object名的前缀Yesstring
delimiterquery具体使用请参考详细的例子。如果delimieter不是空,且prefix不是空字符串,那么prefix必须以delimiter为结尾Nostring
markerquery通过之前一次调用list-objects接口获取;格式类似字符串bucket_name/start_object_name,返回的object字典序都不比strat_object_name小Nostring
maxKeysquery指定最多返回的Object数量,服务端最多返回min(maxKeys, 1000)个object,可能更少Nostring
authorizationheader认证信息,计算方式参考签名认证相关文档Yesstring
Dateheader请求时间Yesstring
Responses
CodeDescriptionSchema
200请求成功ListObjectsResult

Models

ListObjectsResult

NameTypeDescriptionRequired
namestringBucket的名字No
prefixstring调用时指定的prefixNo
maxKeysstring调用时指定的maxKeysNo
markerstring调用时指定的markerNo
truncatedboolean结果是否被分页,如果是true,表示bucket下还有字典序更大的满足条件的Object没有被返回No
nextMarkerstring如果truncated是true,表示下次一次调用需要指定的请求参数marker的值No
objects[ ObjectBean ]object列表No
commonPrefixes[ string ]如果调用时指定了delimiter参数,那么FDS会把delimiter作为分割符分割object的名字,并且把分割后除了最后一部分外的各段前缀作为目录,commonPrefixes保存了当前prefix下的所有目录No
delimiterstring调用时传入的delimiter参数No

ObjectBean

NameTypeDescriptionRequired
namestringobject名字No
ownerOwnerBeanNo
uploadTimelong上传时间戳(UTC),单位毫秒No
sizelong文件大小No

OwnerBean

NameTypeDescriptionRequired
idstring拥有者IDNo

命令行示例

# 列出fds-demo下的所有Object
curl -v -X 'GET' 'http://cnbj0.fds.api.xiaomi.com/fds-demo?delimiter=%2F&prefix=' \
> -H 'authorization: Galaxy-V2 54xxx45:s8xxx1As=' \
> -H 'date: Fri, 24 Feb 2017 07:30:09 GMT'
* Hostname was NOT found in DNS cache
*   Trying 111.206.200.99...
* Connected to cnbj0.fds.api.xiaomi.com (111.206.200.99) port 80 (#0)
> GET /fds-demo?delimiter=%2F&prefix= HTTP/1.1
> User-Agent: curl/7.35.0
> Host: cnbj0.fds.api.xiaomi.com
> Accept: */*
> authorization: Galaxy-V2 54xxx45:s8xxxAs=
> date: Fri, 24 Feb 2017 07:30:09 GMT
> 
< HTTP/1.1 200 OK
* Server Tengine is not blacklisted
< Server: Tengine
< Date: Fri, 24 Feb 2017 07:30:47 GMT
< Content-Type: application/json
< Content-Length: 211
< Connection: keep-alive
< Access-Control-Allow-Credentials: true
< Access-Control-Max-Age: 1728000
< Access-Control-Allow-Methods: GET, POST, PUT, HEAD, DELETE, OPTIONS
< Access-Control-Allow-Headers: DNT,X-Mx-ReqToken,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Authorization,Content-MD5
< Access-Control-Expose-Headers: content-md5, upload-time, x-xiaomi-meta-content-length
< 
* Connection #0 to host cnbj0.fds.api.xiaomi.com left intact
{"commonPrefixes":["bar/","foo/"],"delimiter":"/","marker":"","maxKeys":1000,"name":"fds-demo","objects":[{"name":"bee","owner":{"id":"18xx35"},"size":0,"uploadTime":1487921139433}],"prefix":"","truncated":false}
# 列出fds-demo下的Object,把 '/' 作为分割符
curl -v -X 'GET' 'http://cnbj0.fds.api.xiaomi.com/fds-demo?delimiter=%2F&prefix=' \
> -H 'authorization: Galaxy-V2 54xxx45:rrxx9g=' \
> -H 'date: Fri, 24 Feb 2017 08:36:27 GMT'
* Hostname was NOT found in DNS cache
*   Trying 111.206.200.99...
* Connected to cnbj0.fds.api.xiaomi.com (111.206.200.99) port 80 (#0)
> GET /fds-demo?delimiter=%2F&prefix= HTTP/1.1
> User-Agent: curl/7.35.0
> Host: cnbj0.fds.api.xiaomi.com
> Accept: */*
> authorization: Galaxy-V2 54xxx45:rrxx9g=
> date: Fri, 24 Feb 2017 08:36:27 GMT
> 
< HTTP/1.1 200 OK
* Server Tengine is not blacklisted
< Server: Tengine
< Date: Fri, 24 Feb 2017 08:36:57 GMT
< Content-Type: application/json
< Content-Length: 211
< Connection: keep-alive
< Access-Control-Allow-Credentials: true
< Access-Control-Max-Age: 1728000
< Access-Control-Allow-Methods: GET, POST, PUT, HEAD, DELETE, OPTIONS
< Access-Control-Allow-Headers: DNT,X-Mx-ReqToken,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Authorization,Content-MD5
< Access-Control-Expose-Headers: content-md5, upload-time, x-xiaomi-meta-content-length
< 
* Connection #0 to host cnbj0.fds.api.xiaomi.com left intact
{"commonPrefixes":["bar/","foo/"],"delimiter":"/","marker":"","maxKeys":1000,"name":"fds-demo","objects":[{"name":"bee","owner":{"id":"18xx35"},"size":0,"uploadTime":1487921139433}],"prefix":"","truncated":false}
# 最多返回2条记录
curl -v -X 'GET' 'http://cnbj0.fds.api.xiaomi.com/fds-demo?delimiter=%2F&prefix=&maxKeys=2' \
> -H 'authorization: Galaxy-V2 54xxx45:YcxxxU=' \
> -H 'date: Fri, 24 Feb 2017 08:42:01 GMT'
* Hostname was NOT found in DNS cache
*   Trying 111.206.200.99...
* Connected to cnbj0.fds.api.xiaomi.com (111.206.200.99) port 80 (#0)
> GET /fds-demo?delimiter=%2F&prefix=&maxKeys=2 HTTP/1.1
> User-Agent: curl/7.35.0
> Host: cnbj0.fds.api.xiaomi.com
> Accept: */*
> authorization: Galaxy-V2 54xxx45:YcxxxU=
> date: Fri, 24 Feb 2017 08:42:01 GMT
> 
< HTTP/1.1 200 OK
* Server Tengine is not blacklisted
< Server: Tengine
< Date: Fri, 24 Feb 2017 08:43:02 GMT
< Content-Type: application/json
< Content-Length: 153
< Connection: keep-alive
< Access-Control-Allow-Credentials: true
< Access-Control-Max-Age: 1728000
< Access-Control-Allow-Methods: GET, POST, PUT, HEAD, DELETE, OPTIONS
< Access-Control-Allow-Headers: DNT,X-Mx-ReqToken,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Authorization,Content-MD5
< Access-Control-Expose-Headers: content-md5, upload-time, x-xiaomi-meta-content-length
< 
* Connection #0 to host cnbj0.fds.api.xiaomi.com left intact
{"commonPrefixes":["bar/"],"delimiter":"/","marker":"","maxKeys":2,"name":"fds-demo","nextMarker":"fds-demo/bee","objects":[],"prefix":"","truncated":true}
# 接着上一次继续list剩余的object
curl -v -X 'GET' 'http://cnbj0.fds.api.xiaomi.com/fds-demo?delimiter=%2F&marker=fds-demo%2Fbee&prefix=&maxKeys=2' \
> -H 'authorization: Galaxy-V2 54xxx45:7HxxxQ=' \
> -H 'date: Fri, 24 Feb 2017 08:45:22 GMT'
* Hostname was NOT found in DNS cache
*   Trying 111.206.200.99...
* Connected to cnbj0.fds.api.xiaomi.com (111.206.200.99) port 80 (#0)
> GET /fds-demo?delimiter=%2F&marker=fds-demo%2Fbee&prefix=&maxKeys=2 HTTP/1.1
> User-Agent: curl/7.35.0
> Host: cnbj0.fds.api.xiaomi.com
> Accept: */*
> authorization: Galaxy-V2 54xxx45:7HxxxQ=
> date: Fri, 24 Feb 2017 08:45:22 GMT
> 
< HTTP/1.1 200 OK
* Server Tengine is not blacklisted
< Server: Tengine
< Date: Fri, 24 Feb 2017 08:45:51 GMT
< Content-Type: application/json
< Content-Length: 239
< Connection: keep-alive
< Access-Control-Allow-Credentials: true
< Access-Control-Max-Age: 1728000
< Access-Control-Allow-Methods: GET, POST, PUT, HEAD, DELETE, OPTIONS
< Access-Control-Allow-Headers: DNT,X-Mx-ReqToken,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Authorization,Content-MD5
< Access-Control-Expose-Headers: content-md5, upload-time, x-xiaomi-meta-content-length
< 
* Connection #0 to host cnbj0.fds.api.xiaomi.com left intact
{"commonPrefixes":["foo/"],"delimiter":"/","marker":"fds-demo/bee","maxKeys":2,"name":"fds-demo","nextMarker":"fds-demo/foo0","objects":[{"name":"bee","owner":{"id":"18xx35"},"size":0,"uploadTime":1487921139433}],"prefix":"","truncated":true}