Class MimeManager

java.lang.Object
com.atlassian.jira.util.mime.MimeManager

public class MimeManager extends Object
  • Constructor Summary

    Constructors
    Constructor
    Description
    MimeManager(InputStream mimeTypesInputStream)
     
  • Method Summary

    Modifier and Type
    Method
    Description
    getSanitisedMimeType(String existingMimeType, String fileName)
    If the existing mime type is listed in GENERIC_MIME_TYPES, then return a suggested replacement by looking up the file registered under
    invalid reference
    com.atlassian.jira.ContainerRegistrar#MIME_TYPES_INPUTSTREAM_KEY
    .
    Suggests a mime type for a file name by looking up the file registered under
    invalid reference
    com.atlassian.jira.ContainerRegistrar#MIME_TYPES_INPUTSTREAM_KEY
    .

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • MimeManager

      public MimeManager(InputStream mimeTypesInputStream)
  • Method Details

    • getSanitisedMimeType

      public String getSanitisedMimeType(String existingMimeType, String fileName)
      If the existing mime type is listed in GENERIC_MIME_TYPES, then return a suggested replacement by looking up the file registered under
      invalid reference
      com.atlassian.jira.ContainerRegistrar#MIME_TYPES_INPUTSTREAM_KEY
      . Else return the original mime type.

      Useful when uploading files, and the browser is lazy / sets the wrong content type.

      Parameters:
      existingMimeType - The mime type that we currently know for this file
      fileName - The name of the file
      Returns:
      A suggested replacement if the existing mime type is contained by GENERIC_MIME_TYPES; otherwise, the existing mime type is returned.
      See Also:
      • invalid reference
        com.atlassian.jira.ContainerRegistrar#MIME_TYPES_INPUTSTREAM_KEY
    • getSuggestedMimeType

      public String getSuggestedMimeType(String fileName)
      Suggests a mime type for a file name by looking up the file registered under
      invalid reference
      com.atlassian.jira.ContainerRegistrar#MIME_TYPES_INPUTSTREAM_KEY
      .
      Parameters:
      fileName - The name of the file
      Returns:
      A suggested mime type for a file name;
      See Also:
      • invalid reference
        com.atlassian.jira.ContainerRegistrar#MIME_TYPES_INPUTSTREAM_KEY