MCPcopy Index your code
hub / github.com/cli/cli / typeForFilename

Function typeForFilename

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

Source from the content-addressed store, hash-verified

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