-
Notifications
You must be signed in to change notification settings - Fork 9
/
s3_output.go
67 lines (56 loc) · 1.73 KB
/
s3_output.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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
package awos
import (
"strconv"
"github.com/aws/aws-sdk-go/service/s3"
)
type HeadGetObjectOutputWrapper struct {
getObjectOutput *s3.GetObjectOutput
headObjectOutput *s3.HeadObjectOutput
}
func (h *HeadGetObjectOutputWrapper) getContentType() *string {
if h.getObjectOutput != nil {
return h.getObjectOutput.ContentType
}
return h.headObjectOutput.ContentType
}
func (h *HeadGetObjectOutputWrapper) getContentEncoding() *string {
if h.getObjectOutput != nil {
return h.getObjectOutput.ContentEncoding
}
return h.headObjectOutput.ContentEncoding
}
func (h *HeadGetObjectOutputWrapper) getContentLength() *string {
if h.getObjectOutput != nil && h.getObjectOutput.ContentLength != nil {
clStr := strconv.FormatInt(*h.getObjectOutput.ContentLength, 10)
return &clStr
}
if h.headObjectOutput != nil && h.headObjectOutput.ContentLength != nil {
clStr := strconv.FormatInt(*h.headObjectOutput.ContentLength, 10)
return &clStr
}
clStr := "0"
return &clStr
}
func (h *HeadGetObjectOutputWrapper) getContentDisposition() *string {
if h.getObjectOutput != nil {
return h.getObjectOutput.ContentDisposition
}
return h.headObjectOutput.ContentDisposition
}
func (h *HeadGetObjectOutputWrapper) metaData() map[string]*string {
if h.getObjectOutput != nil {
return h.getObjectOutput.Metadata
}
return h.headObjectOutput.Metadata
}
func mergeHttpStandardHeaders(output *HeadGetObjectOutputWrapper) map[string]*string {
res := make(map[string]*string)
for k, v := range output.metaData() {
res[k] = v
}
res["Content-Length"] = output.getContentLength()
res["Content-Encoding"] = output.getContentEncoding()
res["Content-Type"] = output.getContentType()
res["Content-Disposition"] = output.getContentDisposition()
return res
}