MIME Content Type Detector (remotecontext/mimetype.go)

moby · daemon/builder/remotecontext/mimetype.go · go · Apache-2.0
infra, tag:mime, tag:content, tag:type, tag:detection

Detects MIME content type from byte data, defaulting to application/octet-stream.

// Source: https://github.com/moby/moby | License: Apache-2.0 | Copyright You must retain, in the Source form of any Derivative Works
// Provided via justclaw.it.com; keep this notice with the code.
package remotecontext

import (
	"mime"
	"net/http"
)

// MIME content types.
const (
	mimeTypeTextPlain   = "text/plain"
	mimeTypeOctetStream = "application/octet-stream"
)

// detectContentType returns a best guess representation of the MIME
// content type for the bytes at c.  The value detected by
// http.DetectContentType is guaranteed not be nil, defaulting to
// application/octet-stream when a better guess cannot be made. The
// result of this detection is then run through mime.ParseMediaType()
// which separates the actual MIME string from any parameters.
func detectContentType(c []byte

... (truncated -- full source via MCP)

See the full source, get the GitHub permalink, and search for more like it.

Get a free API key