Update to new changes in objectstorage-go
This commit is contained in:
Generated
+1
-1
@@ -36,7 +36,7 @@
|
||||
},
|
||||
{
|
||||
"ImportPath": "github.com/minio/objectstorage-go",
|
||||
"Rev": "6f9cfd73bc8746e9e1fa42ab8bc619d29785c508"
|
||||
"Rev": "a3c43998a6113bde01aed2ccfd12593f67cc1d19"
|
||||
},
|
||||
{
|
||||
"ImportPath": "github.com/shiena/ansicolor",
|
||||
|
||||
+100
-18
@@ -33,6 +33,9 @@ type API interface {
|
||||
|
||||
// Object Read/Write/Stat operations
|
||||
ObjectAPI
|
||||
|
||||
// MultipartManagementAPI - cancel, list multiparts and active sessions
|
||||
MultipartManagementAPI
|
||||
}
|
||||
|
||||
// BucketAPI - bucket specific Read/Write/Stat interface
|
||||
@@ -55,10 +58,9 @@ type ObjectAPI interface {
|
||||
}
|
||||
|
||||
// MultipartManagementAPI - multi parts management API
|
||||
type MultiPartManagementAPI interface {
|
||||
MultipartAbort(bucket, object, uploadID string) error
|
||||
MultipartAbortRecursive(bucket, object string) <-chan error
|
||||
ListParts(bucket, prefix string, recursive bool) <-chan PartsOnChannel
|
||||
type MultipartManagementAPI interface {
|
||||
MultipartAbort(bucket, prefix string) <-chan error
|
||||
MultipartAbortAll(bucket string) <-chan error
|
||||
}
|
||||
|
||||
// BucketOnChannel - bucket metadata over read channel
|
||||
@@ -73,20 +75,6 @@ type ObjectOnChannel struct {
|
||||
Err error
|
||||
}
|
||||
|
||||
// PartsOnChannel - part metadata over read channel
|
||||
type PartsOnChannel struct {
|
||||
Data *PartMetadata
|
||||
Err error
|
||||
}
|
||||
|
||||
// PartMetadata container for particular part of an object
|
||||
type PartMetadata struct {
|
||||
PartNumber int
|
||||
LastModified time.Time
|
||||
ETag string
|
||||
Size int64
|
||||
}
|
||||
|
||||
// BucketMetadata container for bucket metadata
|
||||
type BucketMetadata struct {
|
||||
// The name of the bucket.
|
||||
@@ -503,3 +491,97 @@ func (a *api) ListBuckets() <-chan BucketOnChannel {
|
||||
go a.listBucketsInRoutine(ch)
|
||||
return ch
|
||||
}
|
||||
|
||||
func (a *api) multipartAbortInRoutine(bucket, prefix string, errorCh chan error) {
|
||||
defer close(errorCh)
|
||||
listMultipartUploadsResult, err := a.listMultipartUploads(bucket, "", "", prefix, "", 1000)
|
||||
if err != nil {
|
||||
errorCh <- err
|
||||
return
|
||||
}
|
||||
for _, upload := range listMultipartUploadsResult.Upload {
|
||||
err := a.abortMultipartUpload(bucket, upload.Key, upload.UploadID)
|
||||
if err != nil {
|
||||
errorCh <- err
|
||||
return
|
||||
}
|
||||
}
|
||||
for {
|
||||
if !listMultipartUploadsResult.IsTruncated {
|
||||
break
|
||||
}
|
||||
listMultipartUploadsResult, err = a.listMultipartUploads(bucket,
|
||||
listMultipartUploadsResult.NextKeyMarker, listMultipartUploadsResult.NextUploadIDMarker, prefix, "", 1000)
|
||||
if err != nil {
|
||||
errorCh <- err
|
||||
return
|
||||
}
|
||||
for _, upload := range listMultipartUploadsResult.Upload {
|
||||
err := a.abortMultipartUpload(bucket, upload.Key, upload.UploadID)
|
||||
if err != nil {
|
||||
errorCh <- err
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
errorCh <- nil
|
||||
}
|
||||
|
||||
/// MultipartManagement operations cancel and list
|
||||
//
|
||||
//
|
||||
// NOTE:
|
||||
// These set of calls require explicit authentication, no anonymous
|
||||
// requests are allowed for multipart API
|
||||
//
|
||||
|
||||
// MultipartAbort - abort a specific in progress active multipart upload, request requires uploadID
|
||||
func (a *api) MultipartAbort(bucket, prefix string) <-chan error {
|
||||
errorCh := make(chan error)
|
||||
go a.multipartAbortInRoutine(bucket, prefix, errorCh)
|
||||
return errorCh
|
||||
}
|
||||
|
||||
func (a *api) multipartAbortAllInRoutine(bucket string, errorCh chan error) {
|
||||
defer close(errorCh)
|
||||
listMultipartUploadsResult, err := a.listMultipartUploads(bucket, "", "", "", "", 1000)
|
||||
if err != nil {
|
||||
errorCh <- err
|
||||
return
|
||||
}
|
||||
for _, upload := range listMultipartUploadsResult.Upload {
|
||||
err := a.abortMultipartUpload(bucket, upload.Key, upload.UploadID)
|
||||
if err != nil {
|
||||
errorCh <- err
|
||||
return
|
||||
}
|
||||
}
|
||||
for {
|
||||
if !listMultipartUploadsResult.IsTruncated {
|
||||
break
|
||||
}
|
||||
listMultipartUploadsResult, err = a.listMultipartUploads(bucket,
|
||||
listMultipartUploadsResult.NextKeyMarker, listMultipartUploadsResult.NextUploadIDMarker, "", "", 1000)
|
||||
if err != nil {
|
||||
errorCh <- err
|
||||
return
|
||||
}
|
||||
for _, upload := range listMultipartUploadsResult.Upload {
|
||||
err := a.abortMultipartUpload(bucket, upload.Key, upload.UploadID)
|
||||
if err != nil {
|
||||
errorCh <- err
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
errorCh <- nil
|
||||
}
|
||||
|
||||
// MultipartAbortAll - abort all inprogress active multipart uploads
|
||||
func (a *api) MultipartAbortAll(bucket string) <-chan error {
|
||||
errorCh := make(chan error)
|
||||
go a.multipartAbortAllInRoutine(bucket, errorCh)
|
||||
return errorCh
|
||||
}
|
||||
|
||||
Generated
Vendored
+39
@@ -0,0 +1,39 @@
|
||||
// +build ignore
|
||||
|
||||
/*
|
||||
* Minimal object storage library (C) 2015 Minio, Inc.
|
||||
*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
package main
|
||||
|
||||
import (
|
||||
"log"
|
||||
|
||||
"github.com/minio/objectstorage-go"
|
||||
)
|
||||
|
||||
func main() {
|
||||
config := new(objectstorage.Config)
|
||||
config.AccessKeyID = ""
|
||||
config.SecretAccessKey = ""
|
||||
config.Region = "us-east-1"
|
||||
config.AcceptType = ""
|
||||
m := objectstorage.New(config)
|
||||
for err := range m.MultipartAbortAll("testbucket") {
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
}
|
||||
}
|
||||
+9
-1
@@ -98,6 +98,14 @@ type initiator struct {
|
||||
DisplayName string
|
||||
}
|
||||
|
||||
// partMetadata container for particular part of an object
|
||||
type partMetadata struct {
|
||||
PartNumber int
|
||||
LastModified time.Time
|
||||
ETag string
|
||||
Size int64
|
||||
}
|
||||
|
||||
// listObjectPartsResult container for ListObjectParts response
|
||||
type listObjectPartsResult struct {
|
||||
Bucket string
|
||||
@@ -114,7 +122,7 @@ type listObjectPartsResult struct {
|
||||
|
||||
// Indicates whether the returned list of parts is truncated.
|
||||
IsTruncated bool
|
||||
Part []*PartMetadata
|
||||
Part []*partMetadata
|
||||
|
||||
EncodingType string
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user