{"id":13872116,"url":"https://github.com/vapor/multipart-kit","last_synced_at":"2025-05-16T03:02:55.684Z","repository":{"id":40315514,"uuid":"76998585","full_name":"vapor/multipart-kit","owner":"vapor","description":"🏞 Parses and serializes multipart-encoded data with Codable support.","archived":false,"fork":false,"pushed_at":"2025-05-13T10:32:59.000Z","size":280,"stargazers_count":156,"open_issues_count":8,"forks_count":45,"subscribers_count":23,"default_branch":"main","last_synced_at":"2025-05-14T01:04:17.362Z","etag":null,"topics":["codable","formdata","multipart","server-side-swift","swift","vapor"],"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/vapor.png","metadata":{"funding":{"github":["vapor"],"open_collective":"vapor"},"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":".github/CODEOWNERS","security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2016-12-20T23:11:25.000Z","updated_at":"2025-04-19T05:31:59.000Z","dependencies_parsed_at":"2024-06-20T00:10:45.244Z","dependency_job_id":"f4473463-8bbe-475d-b2ae-9b6da8b83978","html_url":"https://github.com/vapor/multipart-kit","commit_stats":{"total_commits":123,"total_committers":27,"mean_commits":4.555555555555555,"dds":0.6260162601626016,"last_synced_commit":"a31236f24bfd2ea2f520a74575881f6731d7ae68"},"previous_names":["vapor/multipart"],"tags_count":49,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vapor%2Fmultipart-kit","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vapor%2Fmultipart-kit/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vapor%2Fmultipart-kit/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vapor%2Fmultipart-kit/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/vapor","download_url":"https://codeload.github.com/vapor/multipart-kit/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254459081,"owners_count":22074604,"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":["codable","formdata","multipart","server-side-swift","swift","vapor"],"created_at":"2024-08-05T23:00:34.423Z","updated_at":"2025-05-16T03:02:50.672Z","avatar_url":"https://github.com/vapor.png","language":"Swift","funding_links":["https://github.com/sponsors/vapor","https://opencollective.com/vapor"],"categories":["Swift"],"sub_categories":[],"readme":"\u003cp align=\"center\"\u003e\n\u003cpicture\u003e\n  \u003csource media=\"(prefers-color-scheme: dark)\" srcset=\"https://github.com/vapor/multipart-kit/assets/1130717/4b3aed4e-2b18-4689-80c8-d31ccf169947\"\u003e\n  \u003csource media=\"(prefers-color-scheme: light)\" srcset=\"https://github.com/vapor/multipart-kit/assets/1130717/5c60750b-ef11-4137-9f9e-917ebcc49ca6\"\u003e\n  \u003cimg src=\"https://github.com/vapor/multipart-kit/assets/1130717/5c60750b-ef11-4137-9f9e-917ebcc49ca6\" height=\"96\" alt=\"MultipartKit\"\u003e\n\u003c/picture\u003e \n\u003cbr\u003e\n\u003cbr\u003e\n\u003ca href=\"https://docs.vapor.codes/4.0/\"\u003e\u003cimg src=\"https://design.vapor.codes/images/readthedocs.svg\" alt=\"Documentation\"\u003e\u003c/a\u003e\n\u003ca href=\"https://discord.gg/vapor\"\u003e\u003cimg src=\"https://design.vapor.codes/images/discordchat.svg\" alt=\"Team Chat\"\u003e\u003c/a\u003e\n\u003ca href=\"LICENSE\"\u003e\u003cimg src=\"https://design.vapor.codes/images/mitlicense.svg\" alt=\"MIT License\"\u003e\u003c/a\u003e\n\u003ca href=\"https://github.com/vapor/multipart-kit/actions/workflows/test.yml\"\u003e\u003cimg src=\"https://img.shields.io/github/actions/workflow/status/vapor/multipart-kit/test.yml?event=push\u0026style=plastic\u0026logo=github\u0026label=tests\u0026logoColor=%23ccc\" alt=\"Continuous Integration\"\u003e\u003c/a\u003e\n\u003ca href=\"https://codecov.io/github/vapor/multipart-kit\"\u003e\u003cimg src=\"https://img.shields.io/codecov/c/github/vapor/multipart-kit?style=plastic\u0026logo=codecov\u0026label=Codecov\u0026token=yDzzHja8lt\"\u003e\u003c/a\u003e\n\u003ca href=\"https://swift.org\"\u003e\u003cimg src=\"https://design.vapor.codes/images/swift57up.svg\" alt=\"Swift 5.7+\"\u003e\u003c/a\u003e\n\u003c/p\u003e\n\n🏞 Multipart parser and serializer with `Codable` support for Multipart Form Data.\n\n### Installation\n\nUse the SPM string to easily include the dependency in your `Package.swift` file.\n\nAdd MultipartKit to your package dependencies:\n\n```swift\ndependencies: [\n    // ...\n    .package(url: \"https://github.com/vapor/multipart-kit.git\", from: \"4.0.0\"),\n]\n```\n\nAdd MultipartKit to your target's dependencies:\n\n```swift\ntargets: [\n    .target(name: \"MyAppTarget\", dependencies: [\n        // ...\n        .product(name: \"MultipartKit\", package: \"multipart-kit\"),\n    ])\n]\n```\n\n### Supported Platforms\n\nMultipartKit supports the following platforms:\n\n- All Linux distributions supported by Swift 5.7+\n- macOS 10.15+\n\n## Overview\n\nMultipartKit is a multipart parsing and serializing library. It provides `Codable` support for the special case of the `multipart/form-data` media type through a `FormDataEncoder` and `FormDataDecoder`. The parser delivers its output as it is parsed through callbacks suitable for streaming.\n\n### Multipart Form Data\n\nLet's define a `Codable` type and a choose a boundary used to separate the multipart parts.\n\n```swift\nstruct User: Codable {\n    let name: String\n    let email: String\n}\nlet user = User(name: \"Ed\", email: \"ed@example.com\")\nlet boundary = \"abc123\"\n```\n\nWe can encode this instance of a our type using a `FormDataEncoder`.\n\n```swift\nlet encoded = try FormDataEncoder().encode(foo, boundary: boundary)\n```\n\nThe output looks then looks like this.\n```\n--abc123\nContent-Disposition: form-data; name=\"name\"\n\nEd\n--abc123\nContent-Disposition: form-data; name=\"email\"\n\ned@example.com\n--abc123--\n```\n\nIn order to _decode_ this message we feed this output and the same boundary to a `FormDataDecoder` and we get back an identical instance to the one we started with.\n\n```swift\nlet decoded = try FormDataDecoder().decode(User.self, from: encoded, boundary: boundary)\n```\n\n### A note on `null`\nAs there is no standard defined for how to represent `null` in Multipart (unlike, for instance, JSON), FormDataEncoder and FormDataDecoder do not support encoding or decoding `null` respectively. \n\n### Nesting and Collections\n\nNested structures can be represented by naming the parts such that they describe a path using square brackets to denote contained properties or elements in a collection. The following example shows what that looks like in practice.\n\n```swift\nstruct Nested: Encodable {\n    let tag: String\n    let flag: Bool\n    let nested: [Nested]\n}\nlet boundary = \"abc123\"\nlet nested = Nested(tag: \"a\", flag: true, nested: [Nested(tag: \"b\", flag: false, nested: [])])\nlet encoded = try FormDataEncoder().encode(nested, boundary: boundary)\n```\n\nThis results in the content below.\n\n```\n--abc123\nContent-Disposition: form-data; name=\"tag\"\n\na\n--abc123\nContent-Disposition: form-data; name=\"flag\"\n\ntrue\n--abc123\nContent-Disposition: form-data; name=\"nested[0][tag]\"\n\nb\n--abc123\nContent-Disposition: form-data; name=\"nested[0][flag]\"\n\nfalse\n--abc123--\n```\n\nNote that the array elements always include the index (as opposed to just `[]`) in order to support complex nesting.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fvapor%2Fmultipart-kit","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fvapor%2Fmultipart-kit","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fvapor%2Fmultipart-kit/lists"}