MimeType
Get MIME type string from the extension of a file name
Install / Use
/learn @onevcat/MimeTypeREADME
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.
Related Skills
node-connect
354.3kDiagnose OpenClaw node connection and pairing failures for Android, iOS, and macOS companion apps
frontend-design
112.3kCreate distinctive, production-grade frontend interfaces with high design quality. Use this skill when the user asks to build web components, pages, or applications. Generates creative, polished code that avoids generic AI aesthetics.
openai-whisper-api
354.3kTranscribe audio via OpenAI Audio Transcriptions API (Whisper).
qqbot-media
354.3kQQBot 富媒体收发能力。使用 <qqmedia> 标签,系统根据文件扩展名自动识别类型(图片/语音/视频/文件)。
