@@ -35,6 +35,11 @@ const AwsMultipartDelim = "-"
35
35
// - https://docs.aws.amazon.com/AmazonS3/latest/userguide/UsingMetadata.html#UserMetadata
36
36
const AwsHeaderMetaPrefix = "X-Amz-Meta-"
37
37
38
+ // OCI Object Storage user metadata
39
+ // from: https://docs.oracle.com/en-us/iaas/Content/Object/Tasks/managingobjects.htm
40
+ // User metadata uses the "opc-meta-" prefix (canonicalized to "Opc-Meta-").
41
+ const OCIHeaderMetaPrefix = "Opc-Meta-"
42
+
38
43
func isS3MultipartEtag (etag string ) bool {
39
44
return strings .Contains (etag , AwsMultipartDelim )
40
45
}
@@ -210,14 +215,24 @@ var BackendHelpers = struct {
210
215
return "" , false
211
216
}
212
217
},
213
-
218
+ EncodeMetadata : func (metadata map [string ]string ) (header map [string ]string ) {
219
+ if len (metadata ) == 0 {
220
+ return
221
+ }
222
+ header = make (map [string ]string , len (metadata ))
223
+ for k , v := range metadata {
224
+ key := http .CanonicalHeaderKey (OCIHeaderMetaPrefix + k )
225
+ header [key ] = v
226
+ }
227
+ return
228
+ },
214
229
DecodeMetadata : func (header http.Header ) (metadata map [string ]string ) {
215
230
for headerKey := range header {
216
- if strings .HasPrefix (headerKey , AwsHeaderMetaPrefix ) {
231
+ if strings .HasPrefix (headerKey , OCIHeaderMetaPrefix ) {
217
232
if metadata == nil {
218
233
metadata = make (map [string ]string )
219
234
}
220
- key := strings .TrimPrefix (headerKey , AwsHeaderMetaPrefix )
235
+ key := strings .TrimPrefix (headerKey , OCIHeaderMetaPrefix )
221
236
value := header .Get (headerKey )
222
237
metadata [key ] = value
223
238
}
0 commit comments