swift-mime-type

main

nnabeyang/swift-mime-type

swift-media-type

A swift port of mime package in go. this library provides a function which detects appropriate MIME type for a given file extension.

Usage

import MimeType

loadMimeFile(atPath: "/etc/apache2/mime.types")
print(fileExtension("html")?.serialize() ?? "*/*")  // => "text/html; charset=utf-8"

Adding MimeType as a Dependency

To use the MimeType library in a SwiftPM project, add it to the dependencies for your package:

let package = Package(
    // name, platforms, products, etc.
    dependencies: [
        // other dependencies
        .package(url: "https://github.com/nnabeyang/swift-mime-type", from: "0.0.0"),
    ],
    targets: [
        .executableTarget(name: "<executable-target-name>", dependencies: [
            // other dependencies
            .product(name: "MimeType", package: "swift-mime-type"),
        ]),
        // other targets
    ]
)

License

swift-media-type is published under the MIT License, see LICENSE.

Author

Noriaki Watanabe@nnabeyang

Description

  • Swift Tools 5.6.0
View More Packages from this Author

Dependencies

  • None
Last updated: Thu Apr 09 2026 07:34:04 GMT-0900 (Hawaii-Aleutian Daylight Time)