1
0
mirror of https://github.com/minio/mc.git synced 2025-11-13 12:22:45 +03:00

Migrate to PresignedGetObject from PresignedGetPartialObject() as the latter was of no real use

This commit is contained in:
Harshavardhana
2015-08-21 20:39:22 -07:00
parent 0785fff42b
commit c992bb682f
6 changed files with 15 additions and 24 deletions

View File

@@ -72,7 +72,6 @@ type ObjectAPI interface {
// PresignedAPI - object specific for now // PresignedAPI - object specific for now
type PresignedAPI interface { type PresignedAPI interface {
PresignedGetObject(bucket, object string, expires time.Duration) (string, error) PresignedGetObject(bucket, object string, expires time.Duration) (string, error)
PresignedGetPartialObject(bucket, object string, expires time.Duration, offset, length int64) (string, error)
} }
// BucketStatCh - bucket metadata over read channel // BucketStatCh - bucket metadata over read channel
@@ -235,14 +234,6 @@ func (a apiV2) PresignedGetObject(bucket, object string, expires time.Duration)
return a.presignedGetObject(bucket, object, expireSeconds, 0, 0) return a.presignedGetObject(bucket, object, expireSeconds, 0, 0)
} }
func (a apiV2) PresignedGetPartialObject(bucket, object string, expires time.Duration, offset, length int64) (string, error) {
expireSeconds := int64(expires / time.Second)
if expireSeconds < 1 || expireSeconds > 604800 {
return "", invalidArgumentError("")
}
return a.presignedGetObject(bucket, object, expireSeconds, offset, length)
}
// GetObject retrieve object // GetObject retrieve object
// Downloads full object with no ranges, if you need ranges use GetPartialObject // Downloads full object with no ranges, if you need ranges use GetPartialObject

View File

@@ -6,8 +6,8 @@
"canonical": "github.com/dustin/go-humanize", "canonical": "github.com/dustin/go-humanize",
"comment": "", "comment": "",
"local": "github.com/dustin/go-humanize", "local": "github.com/dustin/go-humanize",
"revision": "555c9466709dddbb3933eb22815b1abf7f6f869f", "revision": "5721d85c9a0e65ee65005e7da48c56612ae04ee3",
"revisionTime": "2015-08-20T20:35:45-07:00" "revisionTime": "2015-08-20T22:35:37-07:00"
}, },
{ {
"canonical": "github.com/fatih/color", "canonical": "github.com/fatih/color",
@@ -20,8 +20,8 @@
"canonical": "github.com/fatih/structs", "canonical": "github.com/fatih/structs",
"comment": "", "comment": "",
"local": "github.com/fatih/structs", "local": "github.com/fatih/structs",
"revision": "555c9466709dddbb3933eb22815b1abf7f6f869f", "revision": "5721d85c9a0e65ee65005e7da48c56612ae04ee3",
"revisionTime": "2015-08-20T20:35:45-07:00" "revisionTime": "2015-08-20T22:35:37-07:00"
}, },
{ {
"canonical": "github.com/mattn/go-isatty", "canonical": "github.com/mattn/go-isatty",
@@ -41,22 +41,22 @@
"canonical": "github.com/minio/minio-go", "canonical": "github.com/minio/minio-go",
"comment": "", "comment": "",
"local": "github.com/minio/minio-go", "local": "github.com/minio/minio-go",
"revision": "feda9e7303c21b33793ce0f8105e8884b5eee6b1", "revision": "d3dc9fd261cacbe64e4c0e5f3929e1fb846db42b",
"revisionTime": "2015-08-17T20:55:25-07:00" "revisionTime": "2015-08-21T20:20:57-07:00"
}, },
{ {
"canonical": "github.com/minio/minio/pkg/probe", "canonical": "github.com/minio/minio/pkg/probe",
"comment": "", "comment": "",
"local": "github.com/minio/minio/pkg/probe", "local": "github.com/minio/minio/pkg/probe",
"revision": "555c9466709dddbb3933eb22815b1abf7f6f869f", "revision": "5721d85c9a0e65ee65005e7da48c56612ae04ee3",
"revisionTime": "2015-08-20T20:35:45-07:00" "revisionTime": "2015-08-20T22:35:37-07:00"
}, },
{ {
"canonical": "github.com/minio/minio/pkg/quick", "canonical": "github.com/minio/minio/pkg/quick",
"comment": "", "comment": "",
"local": "github.com/minio/minio/pkg/quick", "local": "github.com/minio/minio/pkg/quick",
"revision": "555c9466709dddbb3933eb22815b1abf7f6f869f", "revision": "5721d85c9a0e65ee65005e7da48c56612ae04ee3",
"revisionTime": "2015-08-20T20:35:45-07:00" "revisionTime": "2015-08-20T22:35:37-07:00"
}, },
{ {
"canonical": "github.com/minio/pb", "canonical": "github.com/minio/pb",

View File

@@ -35,7 +35,7 @@ type Client interface {
SetBucketACL(acl string) *probe.Error SetBucketACL(acl string) *probe.Error
// Object operations // Object operations
Share(expires time.Duration, offset, length int64) (string, *probe.Error) Share(expires time.Duration) (string, *probe.Error)
GetObject(offset, length int64) (body io.ReadCloser, size int64, err *probe.Error) GetObject(offset, length int64) (body io.ReadCloser, size int64, err *probe.Error)
PutObject(size int64, data io.Reader) *probe.Error PutObject(size int64, data io.Reader) *probe.Error

View File

@@ -122,7 +122,7 @@ func (f *fsClient) get() (io.ReadCloser, int64, *probe.Error) {
} }
} }
func (f *fsClient) Share(expires time.Duration, offset, length int64) (string, *probe.Error) { func (f *fsClient) Share(expires time.Duration) (string, *probe.Error) {
return "", probe.NewError(client.APINotImplemented{API: "Share", APIType: "filesystem"}) return "", probe.NewError(client.APINotImplemented{API: "Share", APIType: "filesystem"})
} }

View File

@@ -102,9 +102,9 @@ func (c *s3Client) GetObject(offset, length int64) (io.ReadCloser, int64, *probe
} }
// Share - get a usable get object url to share // Share - get a usable get object url to share
func (c *s3Client) Share(expires time.Duration, offset, length int64) (string, *probe.Error) { func (c *s3Client) Share(expires time.Duration) (string, *probe.Error) {
bucket, object := c.url2BucketAndObject() bucket, object := c.url2BucketAndObject()
presignedURL, err := c.api.PresignedGetPartialObject(bucket, object, expires, offset, length) presignedURL, err := c.api.PresignedGetObject(bucket, object, expires)
if err != nil { if err != nil {
return "", probe.NewError(err) return "", probe.NewError(err)
} }

View File

@@ -112,7 +112,7 @@ func doShareCmd(targetURL string, recursive bool, expires time.Duration) *probe.
if err != nil { if err != nil {
return err.Trace() return err.Trace()
} }
presignedURL, err := newClnt.Share(expires, 0, 0) presignedURL, err := newClnt.Share(expires)
if err != nil { if err != nil {
return err.Trace() return err.Trace()
} }