Interface nsIMIMEServiceType

The MIME service is responsible for mapping file extensions to MIME-types (see RFC 2045). It also provides access to nsIMIMEInfo interfaces and acts as a general convenience wrapper of nsIMIMEInfo interfaces.

The MIME service maintains a database with a one MIME type to many file extensions rule. Adding the same file extension to multiple MIME types is illegal and behavior is undefined.

See

nsIMIMEInfo

Hierarchy

Methods

  • Increases the reference count for this interface. The associated instance will not be deleted unless the reference count is returned to zero.

    Returns

    The resulting reference count.

    Returns number

  • Parameters

    • aIID: object
    • Optional aInstancePtr: object

    Returns any

  • A run time mechanism for interface discovery.

    Returns

    NS_OK if the interface is supported by the associated instance, NS_NOINTERFACE if it is not.

    aInstancePtr must not be null.

    Parameters

    • aIID: object

      [in] A requested interface IID

    • aInstancePtr: object

      [out] A pointer to an interface pointer to receive the result.

    Returns void

  • Decreases the reference count for this interface. Generally, if the reference count returns to zero, the associated instance is deleted.

    Returns

    The resulting reference count.

    Returns number

  • Retrieves a ACString representation of the MIME type associated with this file extension. Only the default builtin list is examined. Unless you need a restricted set use getTypeFromURI.

    Returns

    The MIME type, if any.

    Parameters

    • aURI: nsIURI

    Returns string

  • Retrieves an nsIMIMEInfo using both the extension and the type of a file. The type is given preference during the lookup. One of aMIMEType and aFileExt can be an empty string. At least one of aMIMEType and aFileExt must be nonempty.

    Parameters

    • aMIMEType: string
    • aFileExt: string

    Returns nsIMIMEInfo

  • Returns an nsIMIMEInfo for the provided MIME type and extension obtained from an OS lookup. If no handler is found for the type and extension, returns a generic nsIMIMEInfo object. The MIME type and extension can be the empty string. When the type and extension don't map to the same handler, the semantics/resolution are platform specific. See the platform implementations for details.

    Returns

    A nsIMIMEInfo object. This function must return a MIMEInfo object if it can allocate one. The only justifiable reason for not returning one is an out-of-memory error.

    Parameters

    • aType: string

      The MIME type to get handler information for.

    • aFileExtension: string

      The filename extension to use either alone or with the MIME type to get handler information for. UTF-8 encoded.

    • aFound: boolean

    Returns nsIMIMEInfo

  • Given a Type/Extension combination, returns the default extension for this type. This may be identical to the passed-in extension.

    Parameters

    • aMIMEType: string

      The Type to get information on. Must not be empty.

    • aFileExt: string

      File Extension. Can be empty.

    Returns string

  • Retrieves a ACString representation of the MIME type associated with this file extension.

    Returns

    The MIME type, if any.

    Parameters

    • aFileExt: string

    Returns string

  • Parameters

    • aFile: nsIFile

    Returns string

  • Retrieves a ACString representation of the MIME type associated with this URI. The association is purely file extension to MIME type based. No attempt to determine the type via server headers or byte scanning is made.

    Returns

    The MIME type, if any.

    Parameters

    • aURI: nsIURI

    Returns string

  • Generate a valid filename from the channel that can be used to save the content of the channel to the local disk.

    The filename is determined from the content disposition, the filename of the uri, or a default filename. The following modifications are applied:

    • If the VALIDATE_SANITIZE_ONLY flag is not specified, then the extension of the filename is modified to suit the supplied content type.
    • Path separators (typically / and ) are replaced by underscores (_)
    • Characters that are not valid or would be confusing in filenames are replaced by spaces (*, :, etc)
    • Bidi related marks are replaced by underscores (_)
    • Whitespace and periods are removed from the beginning and end.
    • Unless VALIDATE_DONT_COLLAPSE_WHITESPACE is specified, multiple consecutive whitespace characters are collapsed to a single space character, either ' ' or an ideographic space 0x3000 if present.
    • Unless VALIDATE_DONT_TRUNCATE is specified, the filename is truncated to a maximum length, preserving the extension if possible.
    • Some filenames and extensions are invalid on certain platforms. These are replaced if possible unless VALIDATE_ALLOW_INVALID_FILENAMES is specified.

    If the VALIDATE_NO_DEFAULT_FILENAME flag is not specified, and after the rules above are applied, the resulting filename is empty, a default filename is used.

    If the VALIDATE_ALLOW_EMPTY flag is specified, an empty string may be returned only if the filename could not be determined or was blank.

    If either the VALIDATE_SANITIZE_ONLY or VALIDATE_GUESS_FROM_EXTENSION flags are specified, then the content type may be empty. Otherwise, the type must not be empty.

    The aOriginalURI would be specified if the channel is for a local file but it was originally sourced from a different uri.

    When saving an image, use validateFileNameForSaving instead and pass the result of imgIRequest::GetFileName() as the filename to check.

    Returns

    The resulting filename.

    Parameters

    • aChannel: nsIChannel

      The channel of the content to save.

    • aType: string

      The MIME type to use, which would usually be the same as the content type of the channel.

    • aOriginalURI: nsIURI
    • aFlags: number

      one or more of the flags above.

    Returns string

  • Update the mime info's default app information based on OS lookups. Note: normally called automatically by nsIMIMEInfo. If you find yourself needing to call this from elsewhere, file a bug instead.

    Parameters

    • aMIMEInfo: nsIMIMEInfo

    Returns void

  • Similar to getValidFileName, but used when a specific filename needs to be validated. The filename is modified as needed based on the content type in the same manner as getValidFileName.

    If the filename came from a uri, it should not be escaped, that is, any needed unescaping of the filename should happen before calling this method.

    Returns

    The validated filename.

    Parameters

    • aFileName: string

      The filename to validate.

    • aType: string

      The MIME type to use.

    • aFlags: number

      one or more of the flags above.

    Returns string

Generated using TypeDoc