diff options
author | Félix Sipma <felix+debian@gueux.org> | 2018-01-05 11:09:44 +0100 |
---|---|---|
committer | Félix Sipma <felix+debian@gueux.org> | 2018-01-05 11:09:44 +0100 |
commit | 9aa20edb43ab70f1865d4d1ae680939faa46c8b7 (patch) | |
tree | 66742c50531fcce59814c2e55f8fa1f0a2e5463f /api-stat.go | |
parent | fd69b3bb0c26856d0938842c0e4e7d3ff959ca3d (diff) | |
parent | 2e53196f9027ebb270b9e9a251ad39383a500c8f (diff) |
Update upstream source from tag 'upstream/4.0.5'
Update to upstream version '4.0.5'
with Debian dir fc9f5488be66217572c92dce9419d3a3fba2cc24
Diffstat (limited to 'api-stat.go')
-rw-r--r-- | api-stat.go | 42 |
1 files changed, 18 insertions, 24 deletions
diff --git a/api-stat.go b/api-stat.go index 4b53032..8904dd6 100644 --- a/api-stat.go +++ b/api-stat.go @@ -1,5 +1,6 @@ /* - * Minio Go Library for Amazon S3 Compatible Cloud Storage (C) 2015, 2016 Minio, Inc. + * Minio Go Library for Amazon S3 Compatible Cloud Storage + * Copyright 2015-2017 Minio, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -17,6 +18,7 @@ package minio import ( + "context" "net/http" "strconv" "strings" @@ -33,9 +35,9 @@ func (c Client) BucketExists(bucketName string) (bool, error) { } // Execute HEAD on bucketName. - resp, err := c.executeMethod("HEAD", requestMetadata{ - bucketName: bucketName, - contentSHA256Bytes: emptySHA256, + resp, err := c.executeMethod(context.Background(), "HEAD", requestMetadata{ + bucketName: bucketName, + contentSHA256Hex: emptySHA256Hex, }) defer closeResponse(resp) if err != nil { @@ -80,7 +82,7 @@ func extractObjMetadata(header http.Header) http.Header { } // StatObject verifies if object exists and you have permission to access. -func (c Client) StatObject(bucketName, objectName string) (ObjectInfo, error) { +func (c Client) StatObject(bucketName, objectName string, opts StatObjectOptions) (ObjectInfo, error) { // Input validation. if err := s3utils.CheckValidBucketName(bucketName); err != nil { return ObjectInfo{}, err @@ -88,12 +90,11 @@ func (c Client) StatObject(bucketName, objectName string) (ObjectInfo, error) { if err := s3utils.CheckValidObjectName(objectName); err != nil { return ObjectInfo{}, err } - reqHeaders := NewHeadReqHeaders() - return c.statObject(bucketName, objectName, reqHeaders) + return c.statObject(context.Background(), bucketName, objectName, opts) } // Lower level API for statObject supporting pre-conditions and range headers. -func (c Client) statObject(bucketName, objectName string, reqHeaders RequestHeaders) (ObjectInfo, error) { +func (c Client) statObject(ctx context.Context, bucketName, objectName string, opts StatObjectOptions) (ObjectInfo, error) { // Input validation. if err := s3utils.CheckValidBucketName(bucketName); err != nil { return ObjectInfo{}, err @@ -102,17 +103,12 @@ func (c Client) statObject(bucketName, objectName string, reqHeaders RequestHead return ObjectInfo{}, err } - customHeader := make(http.Header) - for k, v := range reqHeaders.Header { - customHeader[k] = v - } - // Execute HEAD on objectName. - resp, err := c.executeMethod("HEAD", requestMetadata{ - bucketName: bucketName, - objectName: objectName, - contentSHA256Bytes: emptySHA256, - customHeader: customHeader, + resp, err := c.executeMethod(ctx, "HEAD", requestMetadata{ + bucketName: bucketName, + objectName: objectName, + contentSHA256Hex: emptySHA256Hex, + customHeader: opts.Header(), }) defer closeResponse(resp) if err != nil { @@ -167,11 +163,6 @@ func (c Client) statObject(bucketName, objectName string, reqHeaders RequestHead contentType = "application/octet-stream" } - // Extract only the relevant header keys describing the object. - // following function filters out a list of standard set of keys - // which are not part of object metadata. - metadata := extractObjMetadata(resp.Header) - // Save object metadata info. return ObjectInfo{ ETag: md5sum, @@ -179,6 +170,9 @@ func (c Client) statObject(bucketName, objectName string, reqHeaders RequestHead Size: size, LastModified: date, ContentType: contentType, - Metadata: metadata, + // Extract only the relevant header keys describing the object. + // following function filters out a list of standard set of keys + // which are not part of object metadata. + Metadata: extractObjMetadata(resp.Header), }, nil } |