Marshal converts all the CopyDestOptions into their equivalent HTTP header representation
(header http.Header)
| 121 | // Marshal converts all the CopyDestOptions into their |
| 122 | // equivalent HTTP header representation |
| 123 | func (opts CopyDestOptions) Marshal(header http.Header) { |
| 124 | const replaceDirective = "REPLACE" |
| 125 | if opts.ReplaceTags { |
| 126 | header.Set(amzTaggingHeaderDirective, replaceDirective) |
| 127 | if tags, _ := tags.NewTags(opts.UserTags, true); tags != nil { |
| 128 | header.Set(amzTaggingHeader, tags.String()) |
| 129 | } |
| 130 | } |
| 131 | |
| 132 | if opts.LegalHold != LegalHoldStatus("") { |
| 133 | header.Set(amzLegalHoldHeader, opts.LegalHold.String()) |
| 134 | } |
| 135 | |
| 136 | if opts.Mode != RetentionMode("") && !opts.RetainUntilDate.IsZero() { |
| 137 | header.Set(amzLockMode, opts.Mode.String()) |
| 138 | header.Set(amzLockRetainUntil, opts.RetainUntilDate.Format(time.RFC3339)) |
| 139 | } |
| 140 | |
| 141 | if opts.Encryption != nil { |
| 142 | opts.Encryption.Marshal(header) |
| 143 | } |
| 144 | if opts.ContentType != "" { |
| 145 | header.Set("Content-Type", opts.ContentType) |
| 146 | } |
| 147 | if opts.ContentEncoding != "" { |
| 148 | header.Set("Content-Encoding", opts.ContentEncoding) |
| 149 | } |
| 150 | if opts.ContentDisposition != "" { |
| 151 | header.Set("Content-Disposition", opts.ContentDisposition) |
| 152 | } |
| 153 | if opts.ContentLanguage != "" { |
| 154 | header.Set("Content-Language", opts.ContentLanguage) |
| 155 | } |
| 156 | if opts.CacheControl != "" { |
| 157 | header.Set("Cache-Control", opts.CacheControl) |
| 158 | } |
| 159 | if !opts.Expires.IsZero() { |
| 160 | header.Set("Expires", opts.Expires.UTC().Format(http.TimeFormat)) |
| 161 | } |
| 162 | if opts.ChecksumType.IsSet() { |
| 163 | header.Set(amzChecksumAlgo, opts.ChecksumType.String()) |
| 164 | } |
| 165 | |
| 166 | if opts.AnnotationDirective != "" { |
| 167 | header.Set("x-amz-annotation-directive", opts.AnnotationDirective) |
| 168 | } |
| 169 | |
| 170 | if opts.ReplaceMetadata { |
| 171 | header.Set("x-amz-metadata-directive", replaceDirective) |
| 172 | for k, v := range filterCustomMeta(opts.UserMetadata) { |
| 173 | if isAmzHeader(k) || isStandardHeader(k) || isStorageClassHeader(k) || isMinioHeader(k) { |
| 174 | header.Set(k, v) |
| 175 | } else { |
| 176 | header.Set("x-amz-meta-"+k, v) |
| 177 | } |
| 178 | } |
| 179 | } |
| 180 | } |