GET Objects
API Description
You can use this API to list objects in a bucket. By default, a maximum of 1000 objects are listed.
Method Definition
ObsClient.listObjects
Request Parameter
Field |
Type |
Optional or Mandatory |
Description |
---|---|---|---|
Bucket |
String |
Mandatory |
Bucket name |
RequestDate |
String or Date |
Optional |
Request time
NOTE:
When the parameter type is String, the value must comply with the ISO8601 or RFC822 standards. |
Prefix |
String |
Optional |
Name prefix that the objects to be listed must contain |
Marker |
String |
Optional |
Object name to start with when listing objects in a bucket. All objects are listed in the lexicographical order. |
MaxKeys |
Number |
Optional |
Maximum number of objects returned in the response. The value ranges from 1 to 1000. If the value is not in this range, 1000 is returned by default. |
Delimiter |
String |
Optional |
Character used to group object names. If the object name contains the Delimiter parameter, the character string from the first character to the first delimiter in the object name is grouped under a single result element, CommonPrefix. (If a prefix is specified in the request, the prefix must be removed from the object name.) |
Returned Result (InterfaceResult)
Field |
Type |
Description |
||
---|---|---|---|---|
RequestId |
String |
Request ID returned by the OBS server |
||
Location |
String |
Bucket location |
||
Bucket |
String |
Bucket name |
||
Delimiter |
String |
Character used to group versioning object names, which is consistent with that set in the request |
||
IsTruncated |
String |
Whether all versioning objects are returned. If the field value is true, not all versioning objects are returned. If the field value is false, all versioning objects are returned. |
||
Prefix |
String |
Name prefix of versioning objects, which is consistent with that set in the request |
||
Marker |
String |
Start position for listing objects, which is consistent with that set in the request |
||
NextMarker |
String |
Object name to start with upon the next request for listing objects |
||
MaxKeys |
String |
Maximum number of listed objects, which is consistent with that set in the request |
||
Contents |
Array |
Object list |
||
ETag |
String |
MD5 value of the object (If the object is encrypted using server-side encryption, the ETag is not the MD5 value of the object.) |
||
Size |
String |
Object size in bytes |
||
Key |
String |
Object name |
||
LastModified |
String |
Time when the last modification was made to the object |
||
Owner |
Object |
Object owner |
||
ID |
String |
ID of the domain to which the object owner belongs |
||
StorageClass |
String |
Storage class of the object |
||
Type |
String |
Whether the object is an appendable object |
||
CommonPrefixes |
Array |
List of object name prefixes grouped according to the Delimiter parameter (if specified) |
||
Prefix |
String |
Object name prefix grouped according to the Delimiter parameter |
Sample Code
obsClient.listObjects({ Bucket : 'bucketname', Prefix : 'prefix', MaxKeys : 100 },function (err, result) { if(err){ console.error('Error-->' + err); }else{ if(result.CommonMsg.Status < 300){ console.log('RequestId-->' + result.InterfaceResult.RequestId); for(var j=0;j<result.InterfaceResult.Contents.length;j++){ console.log('Contents[' + j + ']:'); console.log('Key-->' + result.InterfaceResult.Contents[j]['Key']); console.log('LastModified-->' + result.InterfaceResult.Contents[j]['LastModified']); console.log('ETag-->' + result.InterfaceResult.Contents[j]['ETag']); console.log('Size-->' + result.InterfaceResult.Contents[j]['Size']); console.log('Owner[ID]-->' + result.InterfaceResult.Contents[j]['Owner']['ID']); console.log('StorageClass-->' + result.InterfaceResult.Contents[j]['StorageClass']); } }else{ console.log('Code-->' + result.CommonMsg.Code); console.log('Message-->' + result.CommonMsg.Message); } } });
Feedback
Was this page helpful?
Provide feedbackThank you very much for your feedback. We will continue working to improve the documentation.See the reply and handling status in My Cloud VOC.
For any further questions, feel free to contact us through the chatbot.
Chatbot