Implement proper delimiter and prefix handling

With this change Minio server now responds with, delimited
'object names' in conjunction with prefix filtering

~~~
<ListBucketResult>
  <Name>example-bucket</Name>
  <Prefix></Prefix>
  <Marker></Marker>
  <MaxKeys>1000</MaxKeys>
  <Delimiter>/</Delimiter>
  <IsTruncated>false</IsTruncated>
  <Contents>
    <Key>sample.html</Key>
    <LastModified>2011-02-26T01:56:20.000Z</LastModified>
    <ETag>example-bucket#sample.html</ETag>
    <Size>142863</Size>
    <Owner>
      <ID>minio</ID>
      <DisplayName>minio</DisplayName>
    </Owner>
    <StorageClass>STANDARD</StorageClass>
  </Contents>
  <CommonPrefixes>
    <Prefix>photos/</Prefix>
  </CommonPrefixes>
</ListBucketResult>
~~~

~~~
<ListBucketResult>
  <Name>example-bucket</Name>
  <Prefix>photos/2006/</Prefix>
  <Marker></Marker>
  <MaxKeys>1000</MaxKeys>
  <Delimiter>/</Delimiter>
  <IsTruncated>false</IsTruncated>

  <CommonPrefixes>
    <Prefix>photos/2006/feb/</Prefix>
  </CommonPrefixes>
  <CommonPrefixes>
    <Prefix>photos/2006/jan/</Prefix>
  </CommonPrefixes>
</ListBucketResult>
~~~
This commit is contained in:
Harshavardhana
2015-02-28 14:44:26 -08:00
parent acee4d16fd
commit 0c2d58bc6d
5 changed files with 84 additions and 37 deletions

View File

@@ -34,10 +34,8 @@ type ObjectListResponse struct {
MaxKeys int
Delimiter string
IsTruncated bool
Contents []*Item `xml:,innerxml`
CommonPrefixes struct {
Prefix string
} `xml:,innerxml`
Contents []*Item `xml:,innerxml`
CommonPrefixes []*Prefix `xml:,innerxml`
}
// Bucket list response format
@@ -49,6 +47,10 @@ type BucketListResponse struct {
} `xml:,innerxml` // Buckets are nested
}
type Prefix struct {
Prefix string
}
// Bucket struct
type Bucket struct {
Name string