MCPcopy
hub / github.com/danielmiessler/Fabric / detectMimeTypeFromURL

Function detectMimeTypeFromURL

internal/domain/attachment.go:150–161  ·  view source on GitHub ↗
(url string)

Source from the content-addressed store, hash-verified

148}
149
150func detectMimeTypeFromURL(url string) (string, error) {
151 resp, err := http.Head(url)
152 if err != nil {
153 return "", err
154 }
155 defer resp.Body.Close()
156 mimeType := resp.Header.Get("Content-Type")
157 if mimeType == "" {
158 return "", errors.New(i18n.T("attachment_could_not_determine_mimetype"))
159 }
160 return mimeType, nil
161}
162
163func detectMimeTypeFromFile(path string) (string, error) {
164 mime, err := mimetype.DetectFile(path)

Callers 1

NewAttachmentFunction · 0.85

Calls 3

TFunction · 0.92
GetMethod · 0.65
CloseMethod · 0.45

Tested by

no test coverage detected