MCPcopy
hub / github.com/minio/minio-go / validate

Method validate

api-put-object.go:263–299  ·  view source on GitHub ↗

validate() checks if the UserMetadata map has standard headers or and raises an error if so.

(c *Client)

Source from the content-addressed store, hash-verified

261
262// validate() checks if the UserMetadata map has standard headers or and raises an error if so.
263func (opts PutObjectOptions) validate(c *Client) (err error) {
264 for k, v := range opts.UserMetadata {
265 if !httpguts.ValidHeaderFieldName(k) || isStandardHeader(k) || isSSEHeader(k) || isStorageClassHeader(k) || isMinioHeader(k) {
266 return errInvalidArgument(k + " unsupported user defined metadata name")
267 }
268 if !httpguts.ValidHeaderFieldValue(v) {
269 return errInvalidArgument(v + " unsupported user defined metadata value")
270 }
271 }
272 if opts.Mode != "" && !opts.Mode.IsValid() {
273 return errInvalidArgument(opts.Mode.String() + " unsupported retention mode")
274 }
275 if opts.LegalHold != "" && !opts.LegalHold.IsValid() {
276 return errInvalidArgument(opts.LegalHold.String() + " unsupported legal-hold status")
277 }
278
279 checkCrc := false
280 for k := range opts.UserMetadata {
281 if strings.HasPrefix(k, "x-amz-checksum-") {
282 checkCrc = true
283 break
284 }
285 }
286
287 if opts.Checksum.IsSet() || checkCrc {
288 switch {
289 case !c.trailingHeaderSupport:
290 return errInvalidArgument("Checksum requires Client with TrailingHeaders enabled")
291 case c.overrideSignerType.IsV2():
292 return errInvalidArgument("Checksum cannot be used with v2 signatures")
293 case s3utils.IsGoogleEndpoint(*c.endpointURL):
294 return errInvalidArgument("Checksum cannot be used with GCS endpoints")
295 }
296 }
297
298 return nil
299}
300
301// completedParts is a collection of parts sortable by their part numbers.
302// used for sorting the uploaded parts before completing the multipart request.

Callers 4

CopyObjectMethod · 0.45
PutObjectMethod · 0.45
PutObjectsSnowballMethod · 0.45

Calls 10

IsGoogleEndpointFunction · 0.92
isStandardHeaderFunction · 0.85
isSSEHeaderFunction · 0.85
isStorageClassHeaderFunction · 0.85
isMinioHeaderFunction · 0.85
errInvalidArgumentFunction · 0.85
IsV2Method · 0.80
IsValidMethod · 0.45
StringMethod · 0.45
IsSetMethod · 0.45

Tested by 1