Swift 3.0 mime types library
MimeLib is a library that makes it easy to get the right mime type or file extension for your files written in swift
If you want to generate files straight from the Xcode project, you have two options, you can either:
- Pass
"$(SRCROOT)/../Sources/"
as a build argument, this will tell the app the location of the source files - Leave the path empty and the content will be printed into the console
- Convert extension to relevant mime type
- Convert mime type to relevant path extension
.Package(url: "https://github.com/manGoweb/MimeLib.git", majorVersion: 1)
// or
.package(url: "https://github.com/manGoweb/MimeLib.git", .upToNextMajor("1.0.0")),
Couple of examples:
Mime.fileExtension(forMime: "text/plain") // Prints: txt
Mime.fileExtension(forMime: "application/octet-stream") // Prints: bin
Mime.get(fileExtension: "psd")!.rawValue // Prints: image/vnd.adobe.photoshop
Mime.get(fileExtension: "ogg") ?? "nil result" // Prints: nil result
Mime.string(forPath: "/home/file.pdf") // Prints: application/pdf
Please create an issue with a description of your problem or open a pull request with a fix.
MIT
Ondrej Rafaj - http://www.mangoweb.cz/en, @rafiki270