Marshal converts all the CopyDestOptions into their equivalent HTTP header representation
(header http.Header)
| 107 | // Marshal converts all the CopyDestOptions into their |
| 108 | // equivalent HTTP header representation |
| 109 | func (opts CopyDestOptions) Marshal(header http.Header) { |
| 110 | const replaceDirective = "REPLACE" |
| 111 | if opts.ReplaceTags { |
| 112 | header.Set(amzTaggingHeaderDirective, replaceDirective) |
| 113 | if tags, _ := tags.NewTags(opts.UserTags, true); tags != nil { |
| 114 | header.Set(amzTaggingHeader, tags.String()) |
| 115 | } |
| 116 | } |
| 117 | |
| 118 | if opts.LegalHold != LegalHoldStatus("") { |
| 119 | header.Set(amzLegalHoldHeader, opts.LegalHold.String()) |
| 120 | } |
| 121 | |
| 122 | if opts.Mode != RetentionMode("") && !opts.RetainUntilDate.IsZero() { |
| 123 | header.Set(amzLockMode, opts.Mode.String()) |
| 124 | header.Set(amzLockRetainUntil, opts.RetainUntilDate.Format(time.RFC3339)) |
| 125 | } |
| 126 | |
| 127 | if opts.Encryption != nil { |
| 128 | opts.Encryption.Marshal(header) |
| 129 | } |
| 130 | if opts.ContentType != "" { |
| 131 | header.Set("Content-Type", opts.ContentType) |
| 132 | } |
| 133 | if opts.ContentEncoding != "" { |
| 134 | header.Set("Content-Encoding", opts.ContentEncoding) |
| 135 | } |
| 136 | if opts.ContentDisposition != "" { |
| 137 | header.Set("Content-Disposition", opts.ContentDisposition) |
| 138 | } |
| 139 | if opts.ContentLanguage != "" { |
| 140 | header.Set("Content-Language", opts.ContentLanguage) |
| 141 | } |
| 142 | if opts.CacheControl != "" { |
| 143 | header.Set("Cache-Control", opts.CacheControl) |
| 144 | } |
| 145 | if !opts.Expires.IsZero() { |
| 146 | header.Set("Expires", opts.Expires.UTC().Format(http.TimeFormat)) |
| 147 | } |
| 148 | if opts.ChecksumType.IsSet() { |
| 149 | header.Set(amzChecksumAlgo, opts.ChecksumType.String()) |
| 150 | } |
| 151 | |
| 152 | if opts.ReplaceMetadata { |
| 153 | header.Set("x-amz-metadata-directive", replaceDirective) |
| 154 | for k, v := range filterCustomMeta(opts.UserMetadata) { |
| 155 | if isAmzHeader(k) || isStandardHeader(k) || isStorageClassHeader(k) || isMinioHeader(k) { |
| 156 | header.Set(k, v) |
| 157 | } else { |
| 158 | header.Set("x-amz-meta-"+k, v) |
| 159 | } |
| 160 | } |
| 161 | } |
| 162 | } |
| 163 | |
| 164 | // toDestinationInfo returns a validated copyOptions object. |
| 165 | func (opts CopyDestOptions) validate() (err error) { |