Skip to content

Get MIME type string from the extension of a file name

License

Notifications You must be signed in to change notification settings

onevcat/MimeType

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

MimeType

Get mime type from a file path or url extension. Like "text/html" for "/var/www/public/index.html" or "image/png" for "/home/user/cat.png".

Installation

Add the url of this repo to your Package.swift:

import PackageDescription

let package = Package(
    name: "YourAwesomeSoftware",
    dependencies: [
        .Package(url: "https://github.com/onevcat/MimeType.git", 
                 majorVersion: 1)
    ]
)

Then run swift build whenever you get prepared.

You could know more information on how to use Swift Package Manager in Apple's official page.

Usage

let path = "/var/www/public/index.html"
let mime = MimeType(path: path).value
// "text/html"

let url = URL(fileURLWithPath: "/home/user/cat.png")
let anotherMime = MimeType(url: url).value
// "image/png"

License

MIT. See the LICENSE file.

About

Get MIME type string from the extension of a file name

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages