Display storage-class of transitioned object in HEAD

master
Poorna Krishnamoorthy 4 years ago committed by Harshavardhana
parent 95675b0c9a
commit 08b24620c0
  1. 3
      cmd/api-headers.go
  2. 17
      cmd/bucket-lifecycle.go
  3. 10
      cmd/erasure-object.go

@ -200,6 +200,9 @@ func setObjectHeaders(w http.ResponseWriter, objInfo ObjectInfo, rs *HTTPRangeSp
fmt.Sprintf(`expiry-date="%s", rule-id="%s"`, expiryTime.Format(http.TimeFormat), ruleID),
}
}
if objInfo.TransitionStatus == lifecycle.TransitionComplete {
w.Header()[xhttp.AmzStorageClass] = []string{objInfo.StorageClass}
}
}
return nil

@ -168,6 +168,23 @@ func validateTransitionDestination(ctx context.Context, bucket string, targetLab
return sameTarget, arn.Bucket, nil
}
// transitionSC returns storage class label for this bucket
func transitionSC(ctx context.Context, bucket string) string {
cfg, err := globalBucketMetadataSys.GetLifecycleConfig(bucket)
if err != nil {
return ""
}
for _, rule := range cfg.Rules {
if rule.Status == Disabled {
continue
}
if rule.Transition.StorageClass != "" {
return rule.Transition.StorageClass
}
}
return ""
}
// return true if ARN representing transition storage class is present in a active rule
// for the lifecycle configured on this bucket
func transitionSCInUse(ctx context.Context, lfc *lifecycle.Lifecycle, bucket, arnStr string) bool {

@ -424,8 +424,14 @@ func (er erasureObjects) getObjectInfo(ctx context.Context, bucket, object strin
// Make sure to return object info to provide extra information.
return objInfo, toObjectErr(errMethodNotAllowed, bucket, object)
}
return fi.ToObjectInfo(bucket, object), nil
oi := fi.ToObjectInfo(bucket, object)
if oi.TransitionStatus == lifecycle.TransitionComplete {
// overlay storage class for transitioned objects with transition tier SC Label
if sc := transitionSC(ctx, bucket); sc != "" {
oi.StorageClass = sc
}
}
return oi, nil
}
func undoRename(disks []StorageAPI, srcBucket, srcEntry, dstBucket, dstEntry string, isDir bool, errs []error) {

Loading…
Cancel
Save