diff --git a/cmd/disk-cache.go b/cmd/disk-cache.go index 59a3fb7ac..d5aa14ea9 100644 --- a/cmd/disk-cache.go +++ b/cmd/disk-cache.go @@ -58,7 +58,7 @@ type cacheObjects struct { // file path patterns to exclude from cache exclude []string // Object functions pointing to the corresponding functions of backend implementation. - GetObjectNInfoFn func(ctx context.Context, bucket, object string, rs *HTTPRangeSpec, h http.Header, lockType LockType) (gr *GetObjectReader, err error) + GetObjectNInfoFn func(ctx context.Context, bucket, object string, rs *HTTPRangeSpec, h http.Header, lockType LockType, opts ObjectOptions) (gr *GetObjectReader, err error) GetObjectFn func(ctx context.Context, bucket, object string, startOffset int64, length int64, writer io.Writer, etag string, opts ObjectOptions) (err error) GetObjectInfoFn func(ctx context.Context, bucket, object string, opts ObjectOptions) (objInfo ObjectInfo, err error) PutObjectFn func(ctx context.Context, bucket, object string, data *hash.Reader, metadata map[string]string, opts ObjectOptions) (objInfo ObjectInfo, err error) @@ -90,7 +90,7 @@ type CacheObjectLayer interface { ListBuckets(ctx context.Context) (buckets []BucketInfo, err error) DeleteBucket(ctx context.Context, bucket string) error // Object operations. - GetObjectNInfo(ctx context.Context, bucket, object string, rs *HTTPRangeSpec, h http.Header, lockType LockType) (gr *GetObjectReader, err error) + GetObjectNInfo(ctx context.Context, bucket, object string, rs *HTTPRangeSpec, h http.Header, lockType LockType, opts ObjectOptions) (gr *GetObjectReader, err error) GetObject(ctx context.Context, bucket, object string, startOffset int64, length int64, writer io.Writer, etag string, opts ObjectOptions) (err error) GetObjectInfo(ctx context.Context, bucket, object string, opts ObjectOptions) (objInfo ObjectInfo, err error) PutObject(ctx context.Context, bucket, object string, data *hash.Reader, metadata map[string]string, opts ObjectOptions) (objInfo ObjectInfo, err error) @@ -183,9 +183,9 @@ func (c cacheObjects) getMetadata(objInfo ObjectInfo) map[string]string { return metadata } -func (c cacheObjects) GetObjectNInfo(ctx context.Context, bucket, object string, rs *HTTPRangeSpec, h http.Header, lockType LockType) (gr *GetObjectReader, err error) { +func (c cacheObjects) GetObjectNInfo(ctx context.Context, bucket, object string, rs *HTTPRangeSpec, h http.Header, lockType LockType, opts ObjectOptions) (gr *GetObjectReader, err error) { - bkReader, bkErr := c.GetObjectNInfoFn(ctx, bucket, object, rs, h, writeLock) + bkReader, bkErr := c.GetObjectNInfoFn(ctx, bucket, object, rs, h, writeLock, opts) if c.isCacheExclude(bucket, object) || !bkReader.ObjInfo.IsCacheable() { return bkReader, bkErr @@ -210,7 +210,7 @@ func (c cacheObjects) GetObjectNInfo(ctx context.Context, bucket, object string, return bkReader, bkErr } - if cacheReader, cacheErr := dcache.GetObjectNInfo(ctx, bucket, object, rs, h, lockType); cacheErr == nil { + if cacheReader, cacheErr := dcache.GetObjectNInfo(ctx, bucket, object, rs, h, lockType, opts); cacheErr == nil { if backendDown { // If the backend is down, serve the request from cache. return cacheReader, nil diff --git a/cmd/dummy-object-layer_test.go b/cmd/dummy-object-layer_test.go index cf09ff269..e8bcf9430 100644 --- a/cmd/dummy-object-layer_test.go +++ b/cmd/dummy-object-layer_test.go @@ -60,7 +60,7 @@ func (api *DummyObjectLayer) ListObjectsV2(ctx context.Context, bucket, prefix, return } -func (api *DummyObjectLayer) GetObjectNInfo(ctx context.Context, bucket, object string, rs *HTTPRangeSpec, h http.Header, lock LockType) (gr *GetObjectReader, err error) { +func (api *DummyObjectLayer) GetObjectNInfo(ctx context.Context, bucket, object string, rs *HTTPRangeSpec, h http.Header, lock LockType, opts ObjectOptions) (gr *GetObjectReader, err error) { return } diff --git a/cmd/fs-v1.go b/cmd/fs-v1.go index 5592e285b..c0aeeb9f1 100644 --- a/cmd/fs-v1.go +++ b/cmd/fs-v1.go @@ -472,7 +472,7 @@ func (fs *FSObjects) CopyObject(ctx context.Context, srcBucket, srcObject, dstBu // GetObjectNInfo - returns object info and a reader for object // content. -func (fs *FSObjects) GetObjectNInfo(ctx context.Context, bucket, object string, rs *HTTPRangeSpec, h http.Header, lockType LockType) (gr *GetObjectReader, err error) { +func (fs *FSObjects) GetObjectNInfo(ctx context.Context, bucket, object string, rs *HTTPRangeSpec, h http.Header, lockType LockType, opts ObjectOptions) (gr *GetObjectReader, err error) { if err = checkGetObjArgs(ctx, bucket, object); err != nil { return nil, err diff --git a/cmd/gateway/azure/gateway-azure.go b/cmd/gateway/azure/gateway-azure.go index db84c569c..df40fd138 100644 --- a/cmd/gateway/azure/gateway-azure.go +++ b/cmd/gateway/azure/gateway-azure.go @@ -616,9 +616,9 @@ func (a *azureObjects) ListObjectsV2(ctx context.Context, bucket, prefix, contin } // GetObjectNInfo - returns object info and locked object ReadCloser -func (a *azureObjects) GetObjectNInfo(ctx context.Context, bucket, object string, rs *minio.HTTPRangeSpec, h http.Header, lockType minio.LockType) (gr *minio.GetObjectReader, err error) { +func (a *azureObjects) GetObjectNInfo(ctx context.Context, bucket, object string, rs *minio.HTTPRangeSpec, h http.Header, lockType minio.LockType, opts minio.ObjectOptions) (gr *minio.GetObjectReader, err error) { var objInfo minio.ObjectInfo - objInfo, err = a.GetObjectInfo(ctx, bucket, object, minio.ObjectOptions{}) + objInfo, err = a.GetObjectInfo(ctx, bucket, object, opts) if err != nil { return nil, err } @@ -631,7 +631,7 @@ func (a *azureObjects) GetObjectNInfo(ctx context.Context, bucket, object string pr, pw := io.Pipe() go func() { - err := a.GetObject(ctx, bucket, object, startOffset, length, pw, objInfo.ETag, minio.ObjectOptions{}) + err := a.GetObject(ctx, bucket, object, startOffset, length, pw, objInfo.ETag, opts) pw.CloseWithError(err) }() // Setup cleanup function to cause the above go-routine to diff --git a/cmd/gateway/b2/gateway-b2.go b/cmd/gateway/b2/gateway-b2.go index 67eb40b93..771c6aea1 100644 --- a/cmd/gateway/b2/gateway-b2.go +++ b/cmd/gateway/b2/gateway-b2.go @@ -396,9 +396,9 @@ func (l *b2Objects) ListObjectsV2(ctx context.Context, bucket, prefix, continuat } // GetObjectNInfo - returns object info and locked object ReadCloser -func (l *b2Objects) GetObjectNInfo(ctx context.Context, bucket, object string, rs *minio.HTTPRangeSpec, h http.Header, lockType minio.LockType) (gr *minio.GetObjectReader, err error) { +func (l *b2Objects) GetObjectNInfo(ctx context.Context, bucket, object string, rs *minio.HTTPRangeSpec, h http.Header, lockType minio.LockType, opts minio.ObjectOptions) (gr *minio.GetObjectReader, err error) { var objInfo minio.ObjectInfo - objInfo, err = l.GetObjectInfo(ctx, bucket, object, minio.ObjectOptions{}) + objInfo, err = l.GetObjectInfo(ctx, bucket, object, opts) if err != nil { return nil, err } @@ -411,7 +411,7 @@ func (l *b2Objects) GetObjectNInfo(ctx context.Context, bucket, object string, r pr, pw := io.Pipe() go func() { - err := l.GetObject(ctx, bucket, object, startOffset, length, pw, objInfo.ETag, minio.ObjectOptions{}) + err := l.GetObject(ctx, bucket, object, startOffset, length, pw, objInfo.ETag, opts) pw.CloseWithError(err) }() // Setup cleanup function to cause the above go-routine to diff --git a/cmd/gateway/gcs/gateway-gcs.go b/cmd/gateway/gcs/gateway-gcs.go index 4a24b2b8b..810ba48ca 100644 --- a/cmd/gateway/gcs/gateway-gcs.go +++ b/cmd/gateway/gcs/gateway-gcs.go @@ -737,9 +737,9 @@ func (l *gcsGateway) ListObjectsV2(ctx context.Context, bucket, prefix, continua } // GetObjectNInfo - returns object info and locked object ReadCloser -func (l *gcsGateway) GetObjectNInfo(ctx context.Context, bucket, object string, rs *minio.HTTPRangeSpec, h http.Header, lockType minio.LockType) (gr *minio.GetObjectReader, err error) { +func (l *gcsGateway) GetObjectNInfo(ctx context.Context, bucket, object string, rs *minio.HTTPRangeSpec, h http.Header, lockType minio.LockType, opts minio.ObjectOptions) (gr *minio.GetObjectReader, err error) { var objInfo minio.ObjectInfo - objInfo, err = l.GetObjectInfo(ctx, bucket, object, minio.ObjectOptions{}) + objInfo, err = l.GetObjectInfo(ctx, bucket, object, opts) if err != nil { return nil, err } @@ -752,7 +752,7 @@ func (l *gcsGateway) GetObjectNInfo(ctx context.Context, bucket, object string, pr, pw := io.Pipe() go func() { - err := l.GetObject(ctx, bucket, object, startOffset, length, pw, objInfo.ETag, minio.ObjectOptions{}) + err := l.GetObject(ctx, bucket, object, startOffset, length, pw, objInfo.ETag, opts) pw.CloseWithError(err) }() // Setup cleanup function to cause the above go-routine to diff --git a/cmd/gateway/manta/gateway-manta.go b/cmd/gateway/manta/gateway-manta.go index 0a4344eda..3719ec151 100644 --- a/cmd/gateway/manta/gateway-manta.go +++ b/cmd/gateway/manta/gateway-manta.go @@ -507,9 +507,9 @@ func (t *tritonObjects) ListObjectsV2(ctx context.Context, bucket, prefix, conti } // GetObjectNInfo - returns object info and locked object ReadCloser -func (t *tritonObjects) GetObjectNInfo(ctx context.Context, bucket, object string, rs *minio.HTTPRangeSpec, h http.Header, lockType minio.LockType) (gr *minio.GetObjectReader, err error) { +func (t *tritonObjects) GetObjectNInfo(ctx context.Context, bucket, object string, rs *minio.HTTPRangeSpec, h http.Header, lockType minio.LockType, opts minio.ObjectOptions) (gr *minio.GetObjectReader, err error) { var objInfo minio.ObjectInfo - objInfo, err = t.GetObjectInfo(ctx, bucket, object, minio.ObjectOptions{}) + objInfo, err = t.GetObjectInfo(ctx, bucket, object, opts) if err != nil { return nil, err } @@ -522,7 +522,7 @@ func (t *tritonObjects) GetObjectNInfo(ctx context.Context, bucket, object strin pr, pw := io.Pipe() go func() { - err := t.GetObject(ctx, bucket, object, startOffset, length, pw, objInfo.ETag, minio.ObjectOptions{}) + err := t.GetObject(ctx, bucket, object, startOffset, length, pw, objInfo.ETag, opts) pw.CloseWithError(err) }() // Setup cleanup function to cause the above go-routine to diff --git a/cmd/gateway/oss/gateway-oss.go b/cmd/gateway/oss/gateway-oss.go index 92c1bd14c..1d989f43c 100644 --- a/cmd/gateway/oss/gateway-oss.go +++ b/cmd/gateway/oss/gateway-oss.go @@ -547,9 +547,9 @@ func ossGetObject(ctx context.Context, client *oss.Client, bucket, key string, s } // GetObjectNInfo - returns object info and locked object ReadCloser -func (l *ossObjects) GetObjectNInfo(ctx context.Context, bucket, object string, rs *minio.HTTPRangeSpec, h http.Header, lockType minio.LockType) (gr *minio.GetObjectReader, err error) { +func (l *ossObjects) GetObjectNInfo(ctx context.Context, bucket, object string, rs *minio.HTTPRangeSpec, h http.Header, lockType minio.LockType, opts minio.ObjectOptions) (gr *minio.GetObjectReader, err error) { var objInfo minio.ObjectInfo - objInfo, err = l.GetObjectInfo(ctx, bucket, object, minio.ObjectOptions{}) + objInfo, err = l.GetObjectInfo(ctx, bucket, object, opts) if err != nil { return nil, err } @@ -562,7 +562,7 @@ func (l *ossObjects) GetObjectNInfo(ctx context.Context, bucket, object string, pr, pw := io.Pipe() go func() { - err := l.GetObject(ctx, bucket, object, startOffset, length, pw, objInfo.ETag, minio.ObjectOptions{}) + err := l.GetObject(ctx, bucket, object, startOffset, length, pw, objInfo.ETag, opts) pw.CloseWithError(err) }() // Setup cleanup function to cause the above go-routine to diff --git a/cmd/gateway/s3/gateway-s3.go b/cmd/gateway/s3/gateway-s3.go index 3a6090285..b23a3d065 100644 --- a/cmd/gateway/s3/gateway-s3.go +++ b/cmd/gateway/s3/gateway-s3.go @@ -328,9 +328,9 @@ func (l *s3Objects) ListObjectsV2(ctx context.Context, bucket, prefix, continuat } // GetObjectNInfo - returns object info and locked object ReadCloser -func (l *s3Objects) GetObjectNInfo(ctx context.Context, bucket, object string, rs *minio.HTTPRangeSpec, h http.Header, lockType minio.LockType) (gr *minio.GetObjectReader, err error) { +func (l *s3Objects) GetObjectNInfo(ctx context.Context, bucket, object string, rs *minio.HTTPRangeSpec, h http.Header, lockType minio.LockType, opts minio.ObjectOptions) (gr *minio.GetObjectReader, err error) { var objInfo minio.ObjectInfo - objInfo, err = l.GetObjectInfo(ctx, bucket, object, minio.ObjectOptions{}) + objInfo, err = l.GetObjectInfo(ctx, bucket, object, opts) if err != nil { return nil, err } @@ -343,7 +343,7 @@ func (l *s3Objects) GetObjectNInfo(ctx context.Context, bucket, object string, r pr, pw := io.Pipe() go func() { - err := l.GetObject(ctx, bucket, object, startOffset, length, pw, objInfo.ETag, minio.ObjectOptions{}) + err := l.GetObject(ctx, bucket, object, startOffset, length, pw, objInfo.ETag, opts) pw.CloseWithError(err) }() // Setup cleanup function to cause the above go-routine to diff --git a/cmd/gateway/sia/gateway-sia.go b/cmd/gateway/sia/gateway-sia.go index 86036d7fa..6f2f9d71e 100644 --- a/cmd/gateway/sia/gateway-sia.go +++ b/cmd/gateway/sia/gateway-sia.go @@ -432,9 +432,9 @@ func (s *siaObjects) ListObjects(ctx context.Context, bucket string, prefix stri } // GetObjectNInfo - returns object info and locked object ReadCloser -func (s *siaObjects) GetObjectNInfo(ctx context.Context, bucket, object string, rs *minio.HTTPRangeSpec, h http.Header, lockType minio.LockType) (gr *minio.GetObjectReader, err error) { +func (s *siaObjects) GetObjectNInfo(ctx context.Context, bucket, object string, rs *minio.HTTPRangeSpec, h http.Header, lockType minio.LockType, opts minio.ObjectOptions) (gr *minio.GetObjectReader, err error) { var objInfo minio.ObjectInfo - objInfo, err = s.GetObjectInfo(ctx, bucket, object, minio.ObjectOptions{}) + objInfo, err = s.GetObjectInfo(ctx, bucket, object, opts) if err != nil { return nil, err } @@ -447,7 +447,7 @@ func (s *siaObjects) GetObjectNInfo(ctx context.Context, bucket, object string, pr, pw := io.Pipe() go func() { - err := s.GetObject(ctx, bucket, object, startOffset, length, pw, objInfo.ETag, minio.ObjectOptions{}) + err := s.GetObject(ctx, bucket, object, startOffset, length, pw, objInfo.ETag, opts) pw.CloseWithError(err) }() // Setup cleanup function to cause the above go-routine to diff --git a/cmd/object-api-interface.go b/cmd/object-api-interface.go index a587c8512..489810b61 100644 --- a/cmd/object-api-interface.go +++ b/cmd/object-api-interface.go @@ -63,7 +63,7 @@ type ObjectLayer interface { // // IMPORTANTLY, when implementations return err != nil, this // function MUST NOT return a non-nil ReadCloser. - GetObjectNInfo(ctx context.Context, bucket, object string, rs *HTTPRangeSpec, h http.Header, lockType LockType) (reader *GetObjectReader, err error) + GetObjectNInfo(ctx context.Context, bucket, object string, rs *HTTPRangeSpec, h http.Header, lockType LockType, opts ObjectOptions) (reader *GetObjectReader, err error) GetObject(ctx context.Context, bucket, object string, startOffset int64, length int64, writer io.Writer, etag string, opts ObjectOptions) (err error) GetObjectInfo(ctx context.Context, bucket, object string, opts ObjectOptions) (objInfo ObjectInfo, err error) PutObject(ctx context.Context, bucket, object string, data *hash.Reader, metadata map[string]string, opts ObjectOptions) (objInfo ObjectInfo, err error) diff --git a/cmd/object-handlers.go b/cmd/object-handlers.go index 446277913..720bf5726 100644 --- a/cmd/object-handlers.go +++ b/cmd/object-handlers.go @@ -154,7 +154,7 @@ func (api objectAPIHandlers) SelectObjectContentHandler(w http.ResponseWriter, r getObjectNInfo = api.CacheAPI().GetObjectNInfo } - gr, err := getObjectNInfo(ctx, bucket, object, nil, r.Header, readLock) + gr, err := getObjectNInfo(ctx, bucket, object, nil, r.Header, readLock, ObjectOptions{}) if err != nil { writeErrorResponse(w, toAPIErrorCode(err), r.URL) return @@ -287,6 +287,7 @@ func (api objectAPIHandlers) GetObjectHandler(w http.ResponseWriter, r *http.Req vars := mux.Vars(r) bucket := vars["bucket"] object := vars["object"] + var opts ObjectOptions // Check for auth type to return S3 compatible error. // type to return the correct error (NoSuchKey vs AccessDenied) @@ -316,7 +317,7 @@ func (api objectAPIHandlers) GetObjectHandler(w http.ResponseWriter, r *http.Req getObjectInfo = api.CacheAPI().GetObjectInfo } - _, err := getObjectInfo(ctx, bucket, object, ObjectOptions{}) + _, err := getObjectInfo(ctx, bucket, object, opts) if toAPIErrorCode(err) == ErrNoSuchKey { s3Error = ErrNoSuchKey } @@ -349,7 +350,7 @@ func (api objectAPIHandlers) GetObjectHandler(w http.ResponseWriter, r *http.Req } } - gr, err := getObjectNInfo(ctx, bucket, object, rs, r.Header, readLock) + gr, err := getObjectNInfo(ctx, bucket, object, rs, r.Header, readLock, opts) if err != nil { writeErrorResponse(w, toAPIErrorCode(err), r.URL) return @@ -456,7 +457,7 @@ func (api objectAPIHandlers) HeadObjectHandler(w http.ResponseWriter, r *http.Re getObjectInfo = api.CacheAPI().GetObjectInfo } - opts := ObjectOptions{} + var opts ObjectOptions if s3Error := checkRequestAuthType(ctx, r, policy.GetObjectAction, bucket, object); s3Error != ErrNone { if getRequestAuthType(r) == authTypeAnonymous { // As per "Permission" section in @@ -692,7 +693,7 @@ func (api objectAPIHandlers) CopyObjectHandler(w http.ResponseWriter, r *http.Re lock = readLock } - gr, err := getObjectNInfo(ctx, srcBucket, srcObject, rs, r.Header, lock) + gr, err := getObjectNInfo(ctx, srcBucket, srcObject, rs, r.Header, lock, srcOpts) if err != nil { writeErrorResponse(w, toAPIErrorCode(err), r.URL) return @@ -1316,7 +1317,7 @@ func (api objectAPIHandlers) CopyObjectPartHandler(w http.ResponseWriter, r *htt } } - gr, err := getObjectNInfo(ctx, srcBucket, srcObject, rs, r.Header, readLock) + gr, err := getObjectNInfo(ctx, srcBucket, srcObject, rs, r.Header, readLock, srcOpts) if err != nil { writeErrorResponse(w, toAPIErrorCode(err), r.URL) return diff --git a/cmd/xl-sets.go b/cmd/xl-sets.go index 5640fb551..9bd61778a 100644 --- a/cmd/xl-sets.go +++ b/cmd/xl-sets.go @@ -580,8 +580,8 @@ func (s *xlSets) ListBuckets(ctx context.Context) (buckets []BucketInfo, err err // --- Object Operations --- // GetObjectNInfo - returns object info and locked object ReadCloser -func (s *xlSets) GetObjectNInfo(ctx context.Context, bucket, object string, rs *HTTPRangeSpec, h http.Header, lockType LockType) (gr *GetObjectReader, err error) { - return s.getHashedSet(object).GetObjectNInfo(ctx, bucket, object, rs, h, lockType) +func (s *xlSets) GetObjectNInfo(ctx context.Context, bucket, object string, rs *HTTPRangeSpec, h http.Header, lockType LockType, opts ObjectOptions) (gr *GetObjectReader, err error) { + return s.getHashedSet(object).GetObjectNInfo(ctx, bucket, object, rs, h, lockType, opts) } // GetObject - reads an object from the hashedSet based on the object name. diff --git a/cmd/xl-v1-object.go b/cmd/xl-v1-object.go index e705a1098..0c1d5f99f 100644 --- a/cmd/xl-v1-object.go +++ b/cmd/xl-v1-object.go @@ -166,7 +166,7 @@ func (xl xlObjects) CopyObject(ctx context.Context, srcBucket, srcObject, dstBuc // GetObjectNInfo - returns object info and an object // Read(Closer). When err != nil, the returned reader is always nil. -func (xl xlObjects) GetObjectNInfo(ctx context.Context, bucket, object string, rs *HTTPRangeSpec, h http.Header, lockType LockType) (gr *GetObjectReader, err error) { +func (xl xlObjects) GetObjectNInfo(ctx context.Context, bucket, object string, rs *HTTPRangeSpec, h http.Header, lockType LockType, opts ObjectOptions) (gr *GetObjectReader, err error) { var nsUnlocker = func() {} // Acquire lock @@ -220,7 +220,7 @@ func (xl xlObjects) GetObjectNInfo(ctx context.Context, bucket, object string, r pr, pw := io.Pipe() go func() { - err := xl.getObject(ctx, bucket, object, off, length, pw, "", ObjectOptions{}) + err := xl.getObject(ctx, bucket, object, off, length, pw, "", opts) pw.CloseWithError(err) }() // Cleanup function to cause the go routine above to exit, in