{"id":13620661,"url":"https://github.com/sendyhalim/Swime","last_synced_at":"2025-04-14T22:32:13.542Z","repository":{"id":19054837,"uuid":"85831978","full_name":"sendyhalim/Swime","owner":"sendyhalim","description":"🗂 Swift MIME type checking based on magic bytes","archived":true,"fork":false,"pushed_at":"2022-01-27T17:56:13.000Z","size":17638,"stargazers_count":185,"open_issues_count":7,"forks_count":39,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-04-10T09:42:59.412Z","etag":null,"topics":["mime","mime-parser","mime-types","mimetype","swift"],"latest_commit_sha":null,"homepage":"","language":"Swift","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/sendyhalim.png","metadata":{"files":{"readme":"readme.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2017-03-22T13:38:27.000Z","updated_at":"2025-03-03T15:18:02.000Z","dependencies_parsed_at":"2022-08-07T09:01:05.667Z","dependency_job_id":null,"html_url":"https://github.com/sendyhalim/Swime","commit_stats":null,"previous_names":[],"tags_count":16,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sendyhalim%2FSwime","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sendyhalim%2FSwime/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sendyhalim%2FSwime/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sendyhalim%2FSwime/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/sendyhalim","download_url":"https://codeload.github.com/sendyhalim/Swime/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248971986,"owners_count":21191704,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["mime","mime-parser","mime-types","mimetype","swift"],"created_at":"2024-08-01T21:00:58.216Z","updated_at":"2025-04-14T22:32:08.509Z","avatar_url":"https://github.com/sendyhalim.png","language":"Swift","readme":"# 🗂 Swime\nSwift check MIME type based on magic bytes. Swime detects MIME type of a `Data`, ported from [sindresorhus/file-type](https://github.com/sindresorhus/file-type)\n\n[![Build Status](https://travis-ci.org/sendyhalim/Swime.svg?branch=master)](https://travis-ci.org/sendyhalim/Swime)\n\n## Maintainers wanted\nThis project is not under active development, please go to [maintainers ticket](https://github.com/sendyhalim/Swime/issues/24) if you're interested.\n\n[![Maintainers Wanted](https://img.shields.io/badge/maintainers-wanted-red.svg)](https://github.com/pickhardt/maintainers-wanted)\n\n## Installation\n### Swift Package Manager\n```swift\nimport PackageDescription\n\nlet package = Package(\n  name: \"MyApp\",\n  dependencies: [\n    .Package(url: \"https://github.com/sendyhalim/Swime\", majorVersion: 3)\n  ]\n)\n```\n\n## Usage\n\nInspect mime type\n\n```swift\nimport Swime\n\nlet path = \"/path/to/some-file.jpg\"\nlet url = URL(fileURLWithPath: path, isDirectory: false)\nlet data = try! Data(contentsOf: url)\nlet mimeType = Swime.mimeType(data: data)\n\nmimeType?.type == .jpg // true\nmimeType! // MimeType(mime: \"image/jpeg\", ext: \"jpg\", type: .jpg)\n\nswitch mimeType?.type {\n  case .jpg?:\n    ....\n  case .png?:\n    ....\n  case .wmv?:\n    ....\n\n  case ...\n}\n```\n\nPass bytes to it\n```swift\nimport Swime\n\nlet bytes: [UInt8] = [255, 216, 255]\nlet mimeType = Swime.mimeType(bytes: bytes)\n\nmimeType! // MimeType(mime: \"image/jpeg\", ext: \"jpg\", type: .jpg)\n```\n\n## MimeTypeExtension\nHere are the list of available `MimeTypeExtension`.\n\n```swift\npublic enum MimeTypeExtension {\n  case amr\n  case ar\n  case avi\n  case bmp\n  case bz2\n  case cab\n  case cr2\n  case crx\n  case deb\n  case dmg\n  case eot\n  case epub\n  case exe\n  case flac\n  case flif\n  case flv\n  case gif\n  case gz\n  case ico\n  case jpg\n  case jxr\n  case lz\n  case m4a\n  case m4v\n  case mid\n  case mkv\n  case mov\n  case mp3\n  case mp4\n  case mpg\n  case msi\n  case mxf\n  case nes\n  case ogg\n  case opus\n  case otf\n  case pdf\n  case png\n  case ps\n  case psd\n  case rar\n  case rpm\n  case rtf\n  case sevenZ // 7z, Swift does not let us define enum that starts with a digit\n  case sqlite\n  case swf\n  case tar\n  case tif\n  case ttf\n  case wav\n  case webm\n  case webp\n  case wmv\n  case woff\n  case woff2\n  case xpi\n  case xz\n  case z\n  case zip\n  case heic\n}\n```\n\n## Testing\n```\nmake test\n```\n","funding_links":[],"categories":["Swift","S"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsendyhalim%2FSwime","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsendyhalim%2FSwime","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsendyhalim%2FSwime/lists"}