forked from Azure/azure-storage-azcopy
/
gcpModels.go
51 lines (41 loc) · 1.21 KB
/
gcpModels.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
package common
import (
gcpUtils "cloud.google.com/go/storage"
"strings"
)
type GCPObjectInfoExtension struct {
ObjectInfo gcpUtils.ObjectAttrs
}
func (gie *GCPObjectInfoExtension) ContentType() string {
return gie.ObjectInfo.ContentType
}
func (gie *GCPObjectInfoExtension) CacheControl() string {
return gie.ObjectInfo.CacheControl
}
func (gie *GCPObjectInfoExtension) ContentDisposition() string {
return gie.ObjectInfo.ContentDisposition
}
func (gie *GCPObjectInfoExtension) ContentEncoding() string {
return gie.ObjectInfo.ContentEncoding
}
func (gie *GCPObjectInfoExtension) ContentLanguage() string {
return gie.ObjectInfo.ContentLanguage
}
func (gie *GCPObjectInfoExtension) ContentMD5() []byte {
b := gie.ObjectInfo.MD5
return b
}
const gcpMetadataPrefix = "x-goog-meta-"
const gcpMetadataPrefixLen = len(gcpMetadataPrefix)
//NewCommonMetadata returns a map of user-defined key/value pairs
func (gie *GCPObjectInfoExtension) NewCommonMetadata() Metadata {
md := Metadata{}
for k, v := range gie.ObjectInfo.Metadata {
if len(k) > gcpMetadataPrefixLen {
if prefix := k[0:gcpMetadataPrefixLen]; strings.EqualFold(prefix, gcpMetadataPrefix) {
md[k[gcpMetadataPrefixLen:]] = v
}
}
}
return md
}