Skip to content

Mime Types #15

@melvincarvalho

Description

@melvincarvalho
const getContentType = (ext) => {
  switch (ext) {
    // Text
    case '.txt':
      return 'text/plain'
    case '.html':
    case '.htm':
      return 'text/html'
    case '.json':
      return 'application/json'
    case '.css':
      return 'text/css'
    case '.js':
      return 'application/javascript'

    // Images
    case '.jpeg':
    case '.jpg':
      return 'image/jpeg'
    case '.png':
      return 'image/png'
    case '.gif':
      return 'image/gif'
    case '.bmp':
      return 'image/bmp'
    case '.svg':
      return 'image/svg+xml'
    case '.ico':
      return 'image/x-icon'
    case '.webp':
      return 'image/webp'

    // Audio
    case '.mp3':
      return 'audio/mpeg'
    case '.wav':
      return 'audio/wav'
    case '.ogg':
      return 'audio/ogg'
    case '.m4a':
      return 'audio/mp4'
    case '.flac':
      return 'audio/flac'

    // Video
    case '.mp4':
      return 'video/mp4'
    case '.webm':
      return 'video/webm'
    case '.ogv':
      return 'video/ogg'
    case '.mov':
      return 'video/quicktime'
    case '.avi':
      return 'video/x-msvideo'

    // Other
    case '.ttl':
      return 'text/turtle'
    case '.jsonld':
      return 'application/ld+json'
    case '.md':
      return 'text/markdown'
    // this is for the my-mind mindmapping app
    case '.mymind':
      return 'application/json'


    // Default
    default:
      return 'text/html'
  }
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions