Skip to content
`Objective-c` get MIME type based on magic bytes.
Branch: master
Clone or download
Latest commit 73c729a Mar 28, 2019
Type Name Latest commit message Commit time
Failed to load latest commit information.
MHMimeType.xcodeproj fix iOS 8 bug Mar 21, 2019
MHMimeTypeTests add unit test Mar 28, 2019
.gitignore add test units Feb 16, 2019
LICENSE add LICENSE May 22, 2018


Objective-c check MIME type based on magic bytes. MHMimeType detects MIME type of a NSData. Inspired by sendyhalim/Swime


  • iOS 8.0+
  • Xcode 9.0+



Carthage is a decentralized dependency manager that builds your dependencies and provides you with binary frameworks.

You can install Carthage with Homebrew using the following command:

$ brew update
$ brew install carthage

To integrate MHMimeType into your Xcode project using Carthage, specify it in your Cartfile:

github "MakeHui/MHMimeType"

Run carthage update to build the framework and drag the built MHMimeType into your Xcode project.


#import <MHMimeType/MHMimeType.h>

NSString *path = @"file:///Users/ShungYin/Desktop/1.jpg";
MHMimeTypeModel *model = [[MHMimeType sharedInstance] mimeTypeModelWithPath:[NSString stringWithFormat:@"file://%@", path]];
//    MHMimeTypeModel *model = [[MHMimeType sharedInstance] mimeTypeModelWithURL:URL];
//    MHMimeTypeModel *model = [[MHMimeType sharedInstance] mimeTypeModelWithData:data];

NSLog(@"%@", model.mime);
NSLog(@"%@", model.ext);
NSLog(@"%lu", (unsigned long)model.type);


MHMimeType is released under the MIT license. See LICENSE for details.

You can’t perform that action at this time.