MCPcopy Create free account
hub / github.com/cli/cli / typeForFilename

Function typeForFilename

pkg/cmd/release/shared/upload.go:79–105  ·  view source on GitHub ↗
(fn string)

Source from the content-addressed store, hash-verified

77}
78
79func typeForFilename(fn string) string {
80 ext := fileExt(fn)
81 switch ext {
82 case ".zip":
83 return "application/zip"
84 case ".js":
85 return "application/javascript"
86 case ".tar":
87 return "application/x-tar"
88 case ".tgz", ".tar.gz":
89 return "application/x-gtar"
90 case ".bz2":
91 return "application/x-bzip2"
92 case ".dmg":
93 return "application/x-apple-diskimage"
94 case ".rpm":
95 return "application/x-rpm"
96 case ".deb":
97 return "application/x-debian-package"
98 }
99
100 t := mime.TypeByExtension(ext)
101 if t == "" {
102 return "application/octet-stream"
103 }
104 return t
105}
106
107func fileExt(fn string) string {
108 fn = strings.ToLower(fn)

Callers 2

AssetsFromArgsFunction · 0.85
Test_typeForFilenameFunction · 0.85

Calls 1

fileExtFunction · 0.85

Tested by 1

Test_typeForFilenameFunction · 0.68