SwiftyMimeTypes is a database of MIME types and filename extensions. Use it if you need to know the appropriate MIME type for a given filename or the extensions associated with a given MIME type.
SwiftyMimeTypes is a really small library with a simple interface.
// prints "js"
print(MimeTypes.filenameExtension(forType: "application/javascript"))
// prints ["md", "markdown"]
print(MimeTypes.filenameExtensions(forType: "text/markdown"))
// prints "application/javascript"
print(MimeTypes.mimeType(forExtension: "js"))
Xcode 9.x and Swift 4.x (use version 1.x or the swift3
branch for Xcode 8 and Swift 3 compatibility)
SwiftyMimeTypes is available through CocoaPods. To install it, simply add the following line to your Podfile:
pod "SwiftyMimeTypes"
There's no SPM support yet, as there's currently no way to include resources (the mime.types file) with targets. See bug SR-2866 for details.
Daniel Seither, d@fdseither.de
Copyright 2016, 2017, 2018 Daniel Seither <d@fdseither.de>
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.