2015-06-26 05:10:47 -04:00
|
|
|
/*
|
objectAPI: Fix object API interface, remove unnecessary structs.
ObjectAPI changes.
```
ListObjects(bucket, prefix, marker, delimiter string, maxKeys int) (ListObjectsInfo, *probe.Error)
ListMultipartUploads(bucket, objectPrefix, keyMarker, uploadIDMarker, delimiter string, maxUploads int) (ListMultipartsInfo, *probe.Error)
ListObjectParts(bucket, object, uploadID string, partNumberMarker, maxParts int) (ListPartsInfo, *probe.Error)
CompleteMultipartUpload(bucket string, object string, uploadID string, parts []completePart) (ObjectInfo, *probe.Error)
```
2016-04-03 04:34:20 -04:00
|
|
|
* Minio Cloud Storage, (C) 2016 Minio, Inc.
|
2015-06-26 05:10:47 -04:00
|
|
|
*
|
|
|
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
* you may not use this file except in compliance with the License.
|
|
|
|
* You may obtain a copy of the License at
|
|
|
|
*
|
|
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
*
|
|
|
|
* Unless required by applicable law or agreed to in writing, software
|
|
|
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
* See the License for the specific language governing permissions and
|
|
|
|
* limitations under the License.
|
|
|
|
*/
|
|
|
|
|
fs: Break fs package to top-level and introduce ObjectAPI interface.
ObjectAPI interface brings in changes needed for XL ObjectAPI layer.
The new interface for any ObjectAPI layer is as below
```
// ObjectAPI interface.
type ObjectAPI interface {
// Bucket resource API.
DeleteBucket(bucket string) *probe.Error
ListBuckets() ([]BucketInfo, *probe.Error)
MakeBucket(bucket string) *probe.Error
GetBucketInfo(bucket string) (BucketInfo, *probe.Error)
// Bucket query API.
ListObjects(bucket, prefix, marker, delimiter string, maxKeys int) (ListObjectsResult, *probe.Error)
ListMultipartUploads(bucket string, resources BucketMultipartResourcesMetadata) (BucketMultipartResourcesMetadata, *probe.Error)
// Object resource API.
GetObject(bucket, object string, startOffset int64) (io.ReadCloser, *probe.Error)
GetObjectInfo(bucket, object string) (ObjectInfo, *probe.Error)
PutObject(bucket string, object string, size int64, data io.Reader, metadata map[string]string) (ObjectInfo, *probe.Error)
DeleteObject(bucket, object string) *probe.Error
// Object query API.
NewMultipartUpload(bucket, object string) (string, *probe.Error)
PutObjectPart(bucket, object, uploadID string, partID int, size int64, data io.Reader, md5Hex string) (string, *probe.Error)
ListObjectParts(bucket, object string, resources ObjectResourcesMetadata) (ObjectResourcesMetadata, *probe.Error)
CompleteMultipartUpload(bucket string, object string, uploadID string, parts []CompletePart) (ObjectInfo, *probe.Error)
AbortMultipartUpload(bucket, object, uploadID string) *probe.Error
}
```
2016-03-30 19:15:28 -04:00
|
|
|
package main
|
2015-06-26 05:10:47 -04:00
|
|
|
|
2016-04-13 04:00:30 -04:00
|
|
|
import "time"
|
2015-07-04 00:02:31 -04:00
|
|
|
|
2016-05-26 17:13:10 -04:00
|
|
|
// StorageInfo - represents total capacity of underlying storage.
|
|
|
|
type StorageInfo struct {
|
2016-06-09 09:24:11 -04:00
|
|
|
// Total disk space.
|
|
|
|
Total int64
|
|
|
|
// Free available disk space.
|
|
|
|
Free int64
|
2016-05-26 17:13:10 -04:00
|
|
|
}
|
|
|
|
|
2016-06-09 09:24:11 -04:00
|
|
|
// BucketInfo - represents bucket metadata.
|
objectAPI: Fix object API interface, remove unnecessary structs.
ObjectAPI changes.
```
ListObjects(bucket, prefix, marker, delimiter string, maxKeys int) (ListObjectsInfo, *probe.Error)
ListMultipartUploads(bucket, objectPrefix, keyMarker, uploadIDMarker, delimiter string, maxUploads int) (ListMultipartsInfo, *probe.Error)
ListObjectParts(bucket, object, uploadID string, partNumberMarker, maxParts int) (ListPartsInfo, *probe.Error)
CompleteMultipartUpload(bucket string, object string, uploadID string, parts []completePart) (ObjectInfo, *probe.Error)
```
2016-04-03 04:34:20 -04:00
|
|
|
type BucketInfo struct {
|
2016-06-09 09:24:11 -04:00
|
|
|
// Name of the bucket.
|
|
|
|
Name string
|
|
|
|
|
|
|
|
// Date and time when the bucket was created.
|
objectAPI: Fix object API interface, remove unnecessary structs.
ObjectAPI changes.
```
ListObjects(bucket, prefix, marker, delimiter string, maxKeys int) (ListObjectsInfo, *probe.Error)
ListMultipartUploads(bucket, objectPrefix, keyMarker, uploadIDMarker, delimiter string, maxUploads int) (ListMultipartsInfo, *probe.Error)
ListObjectParts(bucket, object, uploadID string, partNumberMarker, maxParts int) (ListPartsInfo, *probe.Error)
CompleteMultipartUpload(bucket string, object string, uploadID string, parts []completePart) (ObjectInfo, *probe.Error)
```
2016-04-03 04:34:20 -04:00
|
|
|
Created time.Time
|
|
|
|
}
|
|
|
|
|
2016-06-09 09:24:11 -04:00
|
|
|
// ObjectInfo - represents object metadata.
|
objectAPI: Fix object API interface, remove unnecessary structs.
ObjectAPI changes.
```
ListObjects(bucket, prefix, marker, delimiter string, maxKeys int) (ListObjectsInfo, *probe.Error)
ListMultipartUploads(bucket, objectPrefix, keyMarker, uploadIDMarker, delimiter string, maxUploads int) (ListMultipartsInfo, *probe.Error)
ListObjectParts(bucket, object, uploadID string, partNumberMarker, maxParts int) (ListPartsInfo, *probe.Error)
CompleteMultipartUpload(bucket string, object string, uploadID string, parts []completePart) (ObjectInfo, *probe.Error)
```
2016-04-03 04:34:20 -04:00
|
|
|
type ObjectInfo struct {
|
2016-06-09 09:24:11 -04:00
|
|
|
// Name of the bucket.
|
|
|
|
Bucket string
|
|
|
|
|
|
|
|
// Name of the object.
|
|
|
|
Name string
|
|
|
|
|
|
|
|
// Date and time when the object was last modified.
|
|
|
|
ModTime time.Time
|
|
|
|
|
|
|
|
// Total object size.
|
|
|
|
Size int64
|
|
|
|
|
|
|
|
// IsDir indicates if the object is prefix.
|
|
|
|
IsDir bool
|
|
|
|
|
|
|
|
// Hex encoded md5 checksum of the object.
|
|
|
|
MD5Sum string
|
|
|
|
|
|
|
|
// A standard MIME type describing the format of the object.
|
|
|
|
ContentType string
|
|
|
|
|
|
|
|
// Specifies what content encodings have been applied to the object and thus
|
|
|
|
// what decoding mechanisms must be applied to obtain the object referenced
|
|
|
|
// by the Content-Type header field.
|
2016-05-19 20:10:08 -04:00
|
|
|
ContentEncoding string
|
2015-07-04 00:02:31 -04:00
|
|
|
}
|
|
|
|
|
2016-06-09 09:24:11 -04:00
|
|
|
// ListPartsInfo - represents list of all parts.
|
objectAPI: Fix object API interface, remove unnecessary structs.
ObjectAPI changes.
```
ListObjects(bucket, prefix, marker, delimiter string, maxKeys int) (ListObjectsInfo, *probe.Error)
ListMultipartUploads(bucket, objectPrefix, keyMarker, uploadIDMarker, delimiter string, maxUploads int) (ListMultipartsInfo, *probe.Error)
ListObjectParts(bucket, object, uploadID string, partNumberMarker, maxParts int) (ListPartsInfo, *probe.Error)
CompleteMultipartUpload(bucket string, object string, uploadID string, parts []completePart) (ObjectInfo, *probe.Error)
```
2016-04-03 04:34:20 -04:00
|
|
|
type ListPartsInfo struct {
|
2016-06-09 09:24:11 -04:00
|
|
|
// Name of the bucket.
|
|
|
|
Bucket string
|
|
|
|
|
|
|
|
// Name of the object.
|
|
|
|
Object string
|
|
|
|
|
|
|
|
// Upload ID identifying the multipart upload whose parts are being listed.
|
|
|
|
UploadID string
|
|
|
|
|
|
|
|
// The class of storage used to store the object.
|
|
|
|
StorageClass string
|
|
|
|
|
|
|
|
// Part number after which listing begins.
|
|
|
|
PartNumberMarker int
|
|
|
|
|
|
|
|
// When a list is truncated, this element specifies the last part in the list,
|
|
|
|
// as well as the value to use for the part-number-marker request parameter
|
|
|
|
// in a subsequent request.
|
2015-07-04 00:02:31 -04:00
|
|
|
NextPartNumberMarker int
|
|
|
|
|
2016-06-09 09:24:11 -04:00
|
|
|
// Maximum number of parts that were allowed in the response.
|
|
|
|
MaxParts int
|
|
|
|
|
|
|
|
// Indicates whether the returned list of parts is truncated.
|
|
|
|
IsTruncated bool
|
|
|
|
|
|
|
|
// List of all parts.
|
|
|
|
Parts []partInfo
|
|
|
|
|
|
|
|
EncodingType string // Not supported yet.
|
2015-07-04 00:02:31 -04:00
|
|
|
}
|
|
|
|
|
2016-06-09 09:24:11 -04:00
|
|
|
// ListMultipartsInfo - represnets bucket resources for incomplete multipart uploads.
|
objectAPI: Fix object API interface, remove unnecessary structs.
ObjectAPI changes.
```
ListObjects(bucket, prefix, marker, delimiter string, maxKeys int) (ListObjectsInfo, *probe.Error)
ListMultipartUploads(bucket, objectPrefix, keyMarker, uploadIDMarker, delimiter string, maxUploads int) (ListMultipartsInfo, *probe.Error)
ListObjectParts(bucket, object, uploadID string, partNumberMarker, maxParts int) (ListPartsInfo, *probe.Error)
CompleteMultipartUpload(bucket string, object string, uploadID string, parts []completePart) (ObjectInfo, *probe.Error)
```
2016-04-03 04:34:20 -04:00
|
|
|
type ListMultipartsInfo struct {
|
2016-06-09 09:24:11 -04:00
|
|
|
// Together with upload-id-marker, this parameter specifies the multipart upload
|
|
|
|
// after which listing should begin.
|
|
|
|
KeyMarker string
|
|
|
|
|
|
|
|
// Together with key-marker, specifies the multipart upload after which listing
|
|
|
|
// should begin. If key-marker is not specified, the upload-id-marker parameter
|
|
|
|
// is ignored.
|
|
|
|
UploadIDMarker string
|
|
|
|
|
|
|
|
// When a list is truncated, this element specifies the value that should be
|
|
|
|
// used for the key-marker request parameter in a subsequent request.
|
|
|
|
NextKeyMarker string
|
|
|
|
|
|
|
|
// When a list is truncated, this element specifies the value that should be
|
|
|
|
// used for the upload-id-marker request parameter in a subsequent request.
|
2015-07-04 00:02:31 -04:00
|
|
|
NextUploadIDMarker string
|
2016-06-09 09:24:11 -04:00
|
|
|
|
|
|
|
// Maximum number of multipart uploads that could have been included in the
|
|
|
|
// response.
|
|
|
|
MaxUploads int
|
|
|
|
|
|
|
|
// Indicates whether the returned list of multipart uploads is truncated. A
|
|
|
|
// value of true indicates that the list was truncated. The list can be truncated
|
|
|
|
// if the number of multipart uploads exceeds the limit allowed or specified
|
|
|
|
// by max uploads.
|
|
|
|
IsTruncated bool
|
|
|
|
|
|
|
|
// List of all pending uploads.
|
|
|
|
Uploads []uploadMetadata
|
|
|
|
|
|
|
|
// When a prefix is provided in the request, The result contains only keys
|
|
|
|
// starting with the specified prefix.
|
|
|
|
Prefix string
|
|
|
|
|
|
|
|
// A character used to truncate the object prefixes.
|
|
|
|
// NOTE: only supported delimiter is '/'.
|
|
|
|
Delimiter string
|
|
|
|
|
|
|
|
// CommonPrefixes contains all (if there are any) keys between Prefix and the
|
|
|
|
// next occurrence of the string specified by delimiter.
|
|
|
|
CommonPrefixes []string
|
|
|
|
|
|
|
|
EncodingType string // Not supported yet.
|
2015-07-04 00:02:31 -04:00
|
|
|
}
|
|
|
|
|
objectAPI: Fix object API interface, remove unnecessary structs.
ObjectAPI changes.
```
ListObjects(bucket, prefix, marker, delimiter string, maxKeys int) (ListObjectsInfo, *probe.Error)
ListMultipartUploads(bucket, objectPrefix, keyMarker, uploadIDMarker, delimiter string, maxUploads int) (ListMultipartsInfo, *probe.Error)
ListObjectParts(bucket, object, uploadID string, partNumberMarker, maxParts int) (ListPartsInfo, *probe.Error)
CompleteMultipartUpload(bucket string, object string, uploadID string, parts []completePart) (ObjectInfo, *probe.Error)
```
2016-04-03 04:34:20 -04:00
|
|
|
// ListObjectsInfo - container for list objects.
|
|
|
|
type ListObjectsInfo struct {
|
2016-06-09 09:24:11 -04:00
|
|
|
// Indicates whether the returned list objects response is truncated. A
|
|
|
|
// value of true indicates that the list was truncated. The list can be truncated
|
|
|
|
// if the number of objects exceeds the limit allowed or specified
|
|
|
|
// by max keys.
|
2016-01-19 20:49:48 -05:00
|
|
|
IsTruncated bool
|
2016-06-09 09:24:11 -04:00
|
|
|
|
|
|
|
// 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
|
|
|
|
// request to get next set of objects.
|
|
|
|
//
|
|
|
|
// NOTE: This element is returned only if you have delimiter request parameter
|
|
|
|
// specified.
|
|
|
|
NextMarker string
|
|
|
|
|
|
|
|
// List of objects info for this request.
|
|
|
|
Objects []ObjectInfo
|
|
|
|
|
|
|
|
// List of prefixes for this request.
|
|
|
|
Prefixes []string
|
2016-01-19 20:49:48 -05:00
|
|
|
}
|
|
|
|
|
2016-06-09 09:24:11 -04:00
|
|
|
// partInfo - represents individual part metadata.
|
objectAPI: Fix object API interface, remove unnecessary structs.
ObjectAPI changes.
```
ListObjects(bucket, prefix, marker, delimiter string, maxKeys int) (ListObjectsInfo, *probe.Error)
ListMultipartUploads(bucket, objectPrefix, keyMarker, uploadIDMarker, delimiter string, maxUploads int) (ListMultipartsInfo, *probe.Error)
ListObjectParts(bucket, object, uploadID string, partNumberMarker, maxParts int) (ListPartsInfo, *probe.Error)
CompleteMultipartUpload(bucket string, object string, uploadID string, parts []completePart) (ObjectInfo, *probe.Error)
```
2016-04-03 04:34:20 -04:00
|
|
|
type partInfo struct {
|
2016-06-09 09:24:11 -04:00
|
|
|
// Part number that identifies the part. This is a positive integer between
|
|
|
|
// 1 and 10,000.
|
|
|
|
PartNumber int
|
|
|
|
|
|
|
|
// Date and time at which the part was uploaded.
|
objectAPI: Fix object API interface, remove unnecessary structs.
ObjectAPI changes.
```
ListObjects(bucket, prefix, marker, delimiter string, maxKeys int) (ListObjectsInfo, *probe.Error)
ListMultipartUploads(bucket, objectPrefix, keyMarker, uploadIDMarker, delimiter string, maxUploads int) (ListMultipartsInfo, *probe.Error)
ListObjectParts(bucket, object, uploadID string, partNumberMarker, maxParts int) (ListPartsInfo, *probe.Error)
CompleteMultipartUpload(bucket string, object string, uploadID string, parts []completePart) (ObjectInfo, *probe.Error)
```
2016-04-03 04:34:20 -04:00
|
|
|
LastModified time.Time
|
2016-06-09 09:24:11 -04:00
|
|
|
|
|
|
|
// Entity tag returned when the part was initially uploaded.
|
|
|
|
ETag string
|
|
|
|
|
|
|
|
// Size in bytes of the part.
|
|
|
|
Size int64
|
objectAPI: Fix object API interface, remove unnecessary structs.
ObjectAPI changes.
```
ListObjects(bucket, prefix, marker, delimiter string, maxKeys int) (ListObjectsInfo, *probe.Error)
ListMultipartUploads(bucket, objectPrefix, keyMarker, uploadIDMarker, delimiter string, maxUploads int) (ListMultipartsInfo, *probe.Error)
ListObjectParts(bucket, object, uploadID string, partNumberMarker, maxParts int) (ListPartsInfo, *probe.Error)
CompleteMultipartUpload(bucket string, object string, uploadID string, parts []completePart) (ObjectInfo, *probe.Error)
```
2016-04-03 04:34:20 -04:00
|
|
|
}
|
|
|
|
|
2016-06-09 09:24:11 -04:00
|
|
|
// uploadMetadata - represents metadata in progress multipart upload.
|
objectAPI: Fix object API interface, remove unnecessary structs.
ObjectAPI changes.
```
ListObjects(bucket, prefix, marker, delimiter string, maxKeys int) (ListObjectsInfo, *probe.Error)
ListMultipartUploads(bucket, objectPrefix, keyMarker, uploadIDMarker, delimiter string, maxUploads int) (ListMultipartsInfo, *probe.Error)
ListObjectParts(bucket, object, uploadID string, partNumberMarker, maxParts int) (ListPartsInfo, *probe.Error)
CompleteMultipartUpload(bucket string, object string, uploadID string, parts []completePart) (ObjectInfo, *probe.Error)
```
2016-04-03 04:34:20 -04:00
|
|
|
type uploadMetadata struct {
|
2016-06-09 09:24:11 -04:00
|
|
|
// Object name for which the multipart upload was initiated.
|
|
|
|
Object string
|
|
|
|
|
|
|
|
// Unique identifier for this multipart upload.
|
|
|
|
UploadID string
|
|
|
|
|
|
|
|
// Date and time at which the multipart upload was initiated.
|
|
|
|
Initiated time.Time
|
|
|
|
|
|
|
|
StorageClass string // Not supported yet.
|
objectAPI: Fix object API interface, remove unnecessary structs.
ObjectAPI changes.
```
ListObjects(bucket, prefix, marker, delimiter string, maxKeys int) (ListObjectsInfo, *probe.Error)
ListMultipartUploads(bucket, objectPrefix, keyMarker, uploadIDMarker, delimiter string, maxUploads int) (ListMultipartsInfo, *probe.Error)
ListObjectParts(bucket, object, uploadID string, partNumberMarker, maxParts int) (ListPartsInfo, *probe.Error)
CompleteMultipartUpload(bucket string, object string, uploadID string, parts []completePart) (ObjectInfo, *probe.Error)
```
2016-04-03 04:34:20 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
// completePart - completed part container.
|
|
|
|
type completePart struct {
|
2016-06-09 09:24:11 -04:00
|
|
|
// Part number identifying the part. This is a positive integer between 1 and
|
|
|
|
// 10,000
|
2015-10-16 14:26:01 -04:00
|
|
|
PartNumber int
|
2016-06-09 09:24:11 -04:00
|
|
|
|
|
|
|
// Entity tag returned when the part was uploaded.
|
|
|
|
ETag string
|
2015-10-16 14:26:01 -04:00
|
|
|
}
|
|
|
|
|
2016-06-09 09:24:11 -04:00
|
|
|
// completedParts - is a collection satisfying sort.Interface.
|
objectAPI: Fix object API interface, remove unnecessary structs.
ObjectAPI changes.
```
ListObjects(bucket, prefix, marker, delimiter string, maxKeys int) (ListObjectsInfo, *probe.Error)
ListMultipartUploads(bucket, objectPrefix, keyMarker, uploadIDMarker, delimiter string, maxUploads int) (ListMultipartsInfo, *probe.Error)
ListObjectParts(bucket, object, uploadID string, partNumberMarker, maxParts int) (ListPartsInfo, *probe.Error)
CompleteMultipartUpload(bucket string, object string, uploadID string, parts []completePart) (ObjectInfo, *probe.Error)
```
2016-04-03 04:34:20 -04:00
|
|
|
type completedParts []completePart
|
2015-10-16 14:26:01 -04:00
|
|
|
|
|
|
|
func (a completedParts) Len() int { return len(a) }
|
|
|
|
func (a completedParts) Swap(i, j int) { a[i], a[j] = a[j], a[i] }
|
|
|
|
func (a completedParts) Less(i, j int) bool { return a[i].PartNumber < a[j].PartNumber }
|
|
|
|
|
2016-06-09 09:24:11 -04:00
|
|
|
// completeMultipartUpload - represents input fields for completing multipart upload.
|
objectAPI: Fix object API interface, remove unnecessary structs.
ObjectAPI changes.
```
ListObjects(bucket, prefix, marker, delimiter string, maxKeys int) (ListObjectsInfo, *probe.Error)
ListMultipartUploads(bucket, objectPrefix, keyMarker, uploadIDMarker, delimiter string, maxUploads int) (ListMultipartsInfo, *probe.Error)
ListObjectParts(bucket, object, uploadID string, partNumberMarker, maxParts int) (ListPartsInfo, *probe.Error)
CompleteMultipartUpload(bucket string, object string, uploadID string, parts []completePart) (ObjectInfo, *probe.Error)
```
2016-04-03 04:34:20 -04:00
|
|
|
type completeMultipartUpload struct {
|
2016-04-13 04:00:30 -04:00
|
|
|
Parts []completePart `xml:"Part"`
|
2015-10-16 14:26:01 -04:00
|
|
|
}
|