From abd9eb781069eb90087d1a0b982d951fa96f3025 Mon Sep 17 00:00:00 2001 From: Anis Elleuch Date: Sat, 18 Nov 2023 21:35:44 -0800 Subject: [PATCH] snowball: Support per object advanced PUT options --- api-putobject-snowball.go | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/api-putobject-snowball.go b/api-putobject-snowball.go index 983ed6744..eb4da4147 100644 --- a/api-putobject-snowball.go +++ b/api-putobject-snowball.go @@ -24,6 +24,7 @@ import ( "context" "fmt" "io" + "net/http" "os" "strings" "sync" @@ -70,6 +71,14 @@ type SnowballObject struct { // Exactly 'Size' number of bytes must be provided. Content io.Reader + // VersionID of the object; if empty, a new versionID will be generated + VersionID string + + // Headers contains more options for this object upload, the same as you + // would include in a regular PutObject operation, such as user metadata + // and content-disposition, expires, .. + Headers http.Header + // Close will be called when an object has finished processing. // Note that if PutObjectsSnowball returns because of an error, // objects not consumed from the input will NOT have been closed. @@ -181,6 +190,14 @@ objectLoop: header.ModTime = time.Now().UTC() } + header.PAXRecords = make(map[string]string) + if obj.VersionID != "" { + header.PAXRecords["minio.versionId"] = obj.VersionID + } + for k, vals := range obj.Headers { + header.PAXRecords["minio.metadata."+k] = strings.Join(vals, ",") + } + if err := t.WriteHeader(&header); err != nil { closeObj() return err