Mimes

org.scalatra.util.Mimes
See theMimes companion object
trait Mimes

A utility to help with mime type detection for a given file path or url.

Attributes

Companion
object
Graph
Supertypes
class Object
trait Matchable
class Any
Known subtypes
object MimeTypes.type

Members list

Value members

Concrete methods

def apply(input: InputStream): String
def apply(file: File): String
def apply(bytes: Array[Byte]): String
def apply(uri: URI): String
def bytesMime(content: Array[Byte], fallback: String): String

Detects the MIME type of a given Byte array.

Detects the MIME type of a given Byte array.

When appropriate MIME Type can not be inferred, "text/pain" is returned.

Value parameters

content

The Byte array for which to detect the MIME type

fallback

A fallback value in case no MIME type can be found

Attributes

def fileMime(file: File, fallback: String): String

Detects the MIME type of a given File.

Detects the MIME type of a given File.

When appropriate MIME Type can not be inferred, "application/octet-stream" is returned.

This method guesses the MIME type using java.net.URLConnection.guessContentTypeFromName. Therefore, by defining an arbitrary MIME type in the configuration file specified by the content.types.user.table property, an arbitrary MIME type can be guessed.

Value parameters

fallback

A fallback value in case no MIME type can be found

file

The File for which to detect the MIME type

Attributes

def inputStreamMime(input: InputStream, fallback: String): String

Detects the MIME type of a given InputStream.

Detects the MIME type of a given InputStream.

When appropriate MIME Type can not be inferred, "application/octet-stream" is returned.

Value parameters

fallback

A fallback value in case no MIME type can be found

input

The InputStream for which to detect the MIME type

Attributes

def urlMime(url: String, fallback: String): String

Detects the MIME type of a given url.

Detects the MIME type of a given url.

When inappropriate MIME Type can not be inferred, "application/octet-stream" is returned.

This method guesses the MIME type using java.net.URLConnection.guessContentTypeFromName. Therefore, by defining an arbitrary MIME type in the configuration file specified by the content.types.user.table property, an arbitrary MIME type can be guessed.

Value parameters

fallback

A fallback value in case no mime type can be found

url

The url for which to detect the mime type

Attributes