LoginSignup
5

More than 5 years have passed since last update.

画像ファイルのmimetypeを取得する

Last updated at Posted at 2017-04-04

Photoフレームワークを使用する。

import Photos

let photo = PHAsset.fetchAssets(withALAssetURLs: [imageURL], options: nil).firstObject

PHImageManager.default().requestImageData(for: photo!, options: nil){ data,string,orientation,hash in

        // mimetype 取得
        let mimeType: String = UTTypeCopyPreferredTagWithClass(string as! CFString, kUTTagClassMIMEType)!.takeRetainedValue() as String
}

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
5