-
Notifications
You must be signed in to change notification settings - Fork 20
/
storage_headers.go
52 lines (45 loc) · 1.48 KB
/
storage_headers.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
package cmd
import (
"github.com/aws/aws-sdk-go-v2/aws"
"github.com/aws/aws-sdk-go-v2/service/s3"
"github.com/spf13/cobra"
)
const (
storageObjectHeaderCacheControl = "Cache-Control"
storageObjectHeaderContentDisposition = "Content-Disposition"
storageObjectHeaderContentEncoding = "Content-Encoding"
storageObjectHeaderContentLanguage = "Content-Language"
storageObjectHeaderContentType = "Content-Type"
storageObjectHeaderExpires = "Expires"
)
var storageHeaderCmd = &cobra.Command{
Use: "headers",
Short: "Manage objects HTTP headers",
}
func init() {
storageCmd.AddCommand(storageHeaderCmd)
}
// storageObjectHeadersFromS3 returns mutable object headers in a human-friendly
// key/value form.
func storageObjectHeadersFromS3(o *s3.GetObjectOutput) map[string]string {
headers := make(map[string]string)
if o.CacheControl != nil {
headers[storageObjectHeaderCacheControl] = aws.ToString(o.CacheControl)
}
if o.ContentDisposition != nil {
headers[storageObjectHeaderContentDisposition] = aws.ToString(o.ContentDisposition)
}
if o.ContentEncoding != nil {
headers[storageObjectHeaderContentEncoding] = aws.ToString(o.ContentEncoding)
}
if o.ContentLanguage != nil {
headers[storageObjectHeaderContentLanguage] = aws.ToString(o.ContentLanguage)
}
if o.ContentType != nil {
headers[storageObjectHeaderContentType] = aws.ToString(o.ContentType)
}
if o.Expires != nil {
headers[storageObjectHeaderExpires] = o.Expires.String()
}
return headers
}