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

Function typeForFilename

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

Source from the content-addressed store, hash-verified

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