diff options
Diffstat (limited to 'api-stat.go')
-rw-r--r-- | api-stat.go | 27 |
1 files changed, 23 insertions, 4 deletions
diff --git a/api-stat.go b/api-stat.go index 91e9d39..5cc40e7 100644 --- a/api-stat.go +++ b/api-stat.go @@ -1,6 +1,6 @@ /* - * Minio Go Library for Amazon S3 Compatible Cloud Storage - * Copyright 2015-2017 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. @@ -24,7 +24,7 @@ import ( "strings" "time" - "github.com/minio/minio-go/pkg/s3utils" + "github.com/minio/minio-go/v6/pkg/s3utils" ) // BucketExists verify if bucket exists and you have permission to access it. @@ -84,6 +84,7 @@ func extractObjMetadata(header http.Header) http.Header { "Content-Length", "Last-Modified", "Content-Type", + "Expires", }, defaultFilterKeys...) return filterHeader(header, filterKeys) } @@ -170,6 +171,22 @@ func (c Client) statObject(ctx context.Context, bucketName, objectName string, o contentType = "application/octet-stream" } + expiryStr := resp.Header.Get("Expires") + var expTime time.Time + if t, err := time.Parse(http.TimeFormat, expiryStr); err == nil { + expTime = t.UTC() + } + + metadata := extractObjMetadata(resp.Header) + userMetadata := map[string]string{} + const xamzmeta = "x-amz-meta-" + const xamzmetaLen = len(xamzmeta) + for k, v := range metadata { + if strings.HasPrefix(strings.ToLower(k), xamzmeta) { + userMetadata[k[xamzmetaLen:]] = v[0] + } + } + // Save object metadata info. return ObjectInfo{ ETag: md5sum, @@ -177,9 +194,11 @@ func (c Client) statObject(ctx context.Context, bucketName, objectName string, o Size: size, LastModified: date, ContentType: contentType, + Expires: expTime, // 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), + Metadata: metadata, + UserMetadata: userMetadata, }, nil } |