mirror of
https://github.com/minio/minio.git
synced 2024-12-24 22:25:54 -05:00
api: ListObjectsV1 compliance with AWS S3. (#2856)
XSD - xml schema definition for SOAP operations on S3 provides positional restrictions on XML output. Fix the response by re-arranging the positions in accordance with S3 behavior. Fixes #2849
This commit is contained in:
parent
6494b77d41
commit
b94211bd66
@ -40,20 +40,9 @@ type LocationResponse struct {
|
|||||||
type ListObjectsResponse struct {
|
type ListObjectsResponse struct {
|
||||||
XMLName xml.Name `xml:"http://s3.amazonaws.com/doc/2006-03-01/ ListBucketResult" json:"-"`
|
XMLName xml.Name `xml:"http://s3.amazonaws.com/doc/2006-03-01/ ListBucketResult" json:"-"`
|
||||||
|
|
||||||
CommonPrefixes []CommonPrefix
|
|
||||||
Contents []Object
|
|
||||||
|
|
||||||
Delimiter string
|
|
||||||
|
|
||||||
// Encoding type used to encode object keys in the response.
|
|
||||||
EncodingType string
|
|
||||||
|
|
||||||
// A flag that indicates whether or not ListObjects returned all of the results
|
|
||||||
// that satisfied the search criteria.
|
|
||||||
IsTruncated bool
|
|
||||||
Marker string
|
|
||||||
MaxKeys int
|
|
||||||
Name string
|
Name string
|
||||||
|
Prefix string
|
||||||
|
Marker string
|
||||||
|
|
||||||
// When response is truncated (the IsTruncated element value in the response
|
// When response is truncated (the IsTruncated element value in the response
|
||||||
// is true), you can use the key name in this field as marker in the subsequent
|
// is true), you can use the key name in this field as marker in the subsequent
|
||||||
@ -62,29 +51,28 @@ type ListObjectsResponse struct {
|
|||||||
// specified. If response does not include the NextMaker and it is truncated,
|
// specified. If response does not include the NextMaker and it is truncated,
|
||||||
// you can use the value of the last Key in the response as the marker in the
|
// you can use the value of the last Key in the response as the marker in the
|
||||||
// subsequent request to get the next set of object keys.
|
// subsequent request to get the next set of object keys.
|
||||||
NextMarker string
|
NextMarker string `xml:"NextMarker,omitempty"`
|
||||||
Prefix string
|
|
||||||
|
MaxKeys int
|
||||||
|
Delimiter string
|
||||||
|
// A flag that indicates whether or not ListObjects returned all of the results
|
||||||
|
// that satisfied the search criteria.
|
||||||
|
IsTruncated bool
|
||||||
|
|
||||||
|
Contents []Object
|
||||||
|
CommonPrefixes []CommonPrefix
|
||||||
|
|
||||||
|
// Encoding type used to encode object keys in the response.
|
||||||
|
EncodingType string `xml:"EncodingType,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// ListObjectsV2Response - format for list objects response.
|
// ListObjectsV2Response - format for list objects response.
|
||||||
type ListObjectsV2Response struct {
|
type ListObjectsV2Response struct {
|
||||||
XMLName xml.Name `xml:"http://s3.amazonaws.com/doc/2006-03-01/ ListBucketResult" json:"-"`
|
XMLName xml.Name `xml:"http://s3.amazonaws.com/doc/2006-03-01/ ListBucketResult" json:"-"`
|
||||||
|
|
||||||
CommonPrefixes []CommonPrefix
|
|
||||||
Contents []Object
|
|
||||||
|
|
||||||
Delimiter string
|
|
||||||
|
|
||||||
// Encoding type used to encode object keys in the response.
|
|
||||||
EncodingType string
|
|
||||||
|
|
||||||
// A flag that indicates whether or not ListObjects returned all of the results
|
|
||||||
// that satisfied the search criteria.
|
|
||||||
IsTruncated bool
|
|
||||||
StartAfter string
|
|
||||||
MaxKeys int
|
|
||||||
Name string
|
Name string
|
||||||
|
Prefix string
|
||||||
|
StartAfter string `xml:"StartAfter,omitempty"`
|
||||||
// When response is truncated (the IsTruncated element value in the response
|
// When response is truncated (the IsTruncated element value in the response
|
||||||
// is true), you can use the key name in this field as marker in the subsequent
|
// is true), you can use the key name in this field as marker in the subsequent
|
||||||
// request to get next set of objects. Server lists objects in alphabetical
|
// request to get next set of objects. Server lists objects in alphabetical
|
||||||
@ -92,16 +80,28 @@ type ListObjectsV2Response struct {
|
|||||||
// specified. If response does not include the NextMaker and it is truncated,
|
// specified. If response does not include the NextMaker and it is truncated,
|
||||||
// you can use the value of the last Key in the response as the marker in the
|
// you can use the value of the last Key in the response as the marker in the
|
||||||
// subsequent request to get the next set of object keys.
|
// subsequent request to get the next set of object keys.
|
||||||
ContinuationToken string
|
ContinuationToken string `xml:"ContinuationToken,omitempty"`
|
||||||
NextContinuationToken string
|
NextContinuationToken string `xml:"NextContinuationToken,omitempty"`
|
||||||
Prefix string
|
|
||||||
|
KeyCount int
|
||||||
|
MaxKeys int
|
||||||
|
Delimiter string
|
||||||
|
// A flag that indicates whether or not ListObjects returned all of the results
|
||||||
|
// that satisfied the search criteria.
|
||||||
|
IsTruncated bool
|
||||||
|
|
||||||
|
Contents []Object
|
||||||
|
CommonPrefixes []CommonPrefix
|
||||||
|
|
||||||
|
// Encoding type used to encode object keys in the response.
|
||||||
|
EncodingType string `xml:"EncodingType,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// Part container for part metadata.
|
// Part container for part metadata.
|
||||||
type Part struct {
|
type Part struct {
|
||||||
PartNumber int
|
PartNumber int
|
||||||
ETag string
|
|
||||||
LastModified string
|
LastModified string
|
||||||
|
ETag string
|
||||||
Size int64
|
Size int64
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -137,23 +137,29 @@ type ListMultipartUploadsResponse struct {
|
|||||||
UploadIDMarker string `xml:"UploadIdMarker"`
|
UploadIDMarker string `xml:"UploadIdMarker"`
|
||||||
NextKeyMarker string
|
NextKeyMarker string
|
||||||
NextUploadIDMarker string `xml:"NextUploadIdMarker"`
|
NextUploadIDMarker string `xml:"NextUploadIdMarker"`
|
||||||
EncodingType string
|
Delimiter string
|
||||||
|
Prefix string
|
||||||
|
EncodingType string `xml:"EncodingType,omitempty"`
|
||||||
MaxUploads int
|
MaxUploads int
|
||||||
IsTruncated bool
|
IsTruncated bool
|
||||||
|
|
||||||
|
// List of pending uploads.
|
||||||
Uploads []Upload `xml:"Upload"`
|
Uploads []Upload `xml:"Upload"`
|
||||||
Prefix string
|
|
||||||
Delimiter string
|
// Delimed common prefixes.
|
||||||
CommonPrefixes []CommonPrefix
|
CommonPrefixes []CommonPrefix
|
||||||
}
|
}
|
||||||
|
|
||||||
// ListBucketsResponse - format for list buckets response
|
// ListBucketsResponse - format for list buckets response
|
||||||
type ListBucketsResponse struct {
|
type ListBucketsResponse struct {
|
||||||
XMLName xml.Name `xml:"http://s3.amazonaws.com/doc/2006-03-01/ ListAllMyBucketsResult" json:"-"`
|
XMLName xml.Name `xml:"http://s3.amazonaws.com/doc/2006-03-01/ ListAllMyBucketsResult" json:"-"`
|
||||||
|
|
||||||
|
Owner Owner
|
||||||
|
|
||||||
// Container for one or more buckets.
|
// Container for one or more buckets.
|
||||||
Buckets struct {
|
Buckets struct {
|
||||||
Buckets []Bucket `xml:"Bucket"`
|
Buckets []Bucket `xml:"Bucket"`
|
||||||
} // Buckets are nested
|
} // Buckets are nested
|
||||||
Owner Owner
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Upload container for in progress multipart upload
|
// Upload container for in progress multipart upload
|
||||||
@ -179,23 +185,23 @@ type Bucket struct {
|
|||||||
|
|
||||||
// Object container for object metadata
|
// Object container for object metadata
|
||||||
type Object struct {
|
type Object struct {
|
||||||
ETag string
|
|
||||||
Key string
|
Key string
|
||||||
LastModified string // time string of format "2006-01-02T15:04:05.000Z"
|
LastModified string // time string of format "2006-01-02T15:04:05.000Z"
|
||||||
|
ETag string
|
||||||
Size int64
|
Size int64
|
||||||
|
|
||||||
|
// Owner of the object.
|
||||||
Owner Owner
|
Owner Owner
|
||||||
|
|
||||||
// The class of storage used to store the object.
|
// The class of storage used to store the object.
|
||||||
StorageClass string
|
StorageClass string
|
||||||
}
|
}
|
||||||
|
|
||||||
// CopyObjectResponse container returns ETag and LastModified of the
|
// CopyObjectResponse container returns ETag and LastModified of the successfully copied object
|
||||||
// successfully copied object
|
|
||||||
type CopyObjectResponse struct {
|
type CopyObjectResponse struct {
|
||||||
XMLName xml.Name `xml:"http://s3.amazonaws.com/doc/2006-03-01/ CopyObjectResult" json:"-"`
|
XMLName xml.Name `xml:"http://s3.amazonaws.com/doc/2006-03-01/ CopyObjectResult" json:"-"`
|
||||||
ETag string
|
|
||||||
LastModified string // time string of format "2006-01-02T15:04:05.000Z"
|
LastModified string // time string of format "2006-01-02T15:04:05.000Z"
|
||||||
|
ETag string // md5sum of the copied object.
|
||||||
}
|
}
|
||||||
|
|
||||||
// Initiator inherit from Owner struct, fields are same
|
// Initiator inherit from Owner struct, fields are same
|
||||||
@ -370,6 +376,7 @@ func generateListObjectsV2Response(bucket, prefix, token, startAfter, delimiter
|
|||||||
prefixes = append(prefixes, prefixItem)
|
prefixes = append(prefixes, prefixItem)
|
||||||
}
|
}
|
||||||
data.CommonPrefixes = prefixes
|
data.CommonPrefixes = prefixes
|
||||||
|
data.KeyCount = len(data.Contents) + len(data.CommonPrefixes)
|
||||||
return data
|
return data
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user