# SSWG-0017: MultipartKit

**URL:** <https://forums.swift.org/t/sswg-0017-multipartkit/52586>\
**Category:** Proposals\
**Created:** [October 4, 2021, 4:58pm UTC](https://forums.swift.org/t/sswg-0017-multipartkit/52586 "2021-10-04T16:58:48Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![kmahar](https://sea2.discourse-cdn.com/swift/user_avatar/forums.swift.org/kmahar/32/5380_2.png) [@kmahar](https://forums.swift.org/u/kmahar)\
**Post date:** [October 4, 2021, 4:58pm UTC](https://forums.swift.org/t/sswg-0017-multipartkit/52586/1 "2021-10-04T16:58:48Z")

</div>

The review of [SSWG-0017: MultipartKit](https://github.com/swift-server/sswg/blob/main/proposals/0017-multipart-kit.md) begins now and runs through October 18, 2021.

Reviews are an important part of the Swift Server Work Group [incubation process](https://github.com/swift-server/sswg/blob/master/process/incubation.md#process). All review feedback should be either on this forum thread or, if you would like to keep your feedback private, directly to the review manager (via [email](mailto:kaitlin.mahar@mongodb.com) or direct message in the Swift forums).

## What goes into a review of a proposal?

The goal of the review process is to improve the proposal under review through constructive criticism and, eventually, become listed on the Swift Server Ecosystem [index page](https://swift.org/sswg/#projects).

When reviewing a proposal, here are some questions to consider:

- What is your evaluation of the proposal and its APIs/implementation?
- Is the problem being addressed relevant for the wider Swift on Server ecosystem?
- Does this proposal fit well with the feel and direction of the Swift Server ecosystem?
- If you have used other libraries in Swift or other languages, how do you feel that this proposal compares to those?
- How much effort did you put into your review? A glance, a quick reading, or an in-depth study?

Thanks,  
Kaitlin Mahar  
Review Manager

---

<div class="post-metadata">

**Author:** ![adam-fowler](https://sea2.discourse-cdn.com/swift/user_avatar/forums.swift.org/adam-fowler/32/9266_2.png) [@adam-fowler](https://forums.swift.org/u/adam-fowler)\
**Post date:** [October 5, 2021, 9:25am UTC](https://forums.swift.org/t/sswg-0017-multipartkit/52586/2 "2021-10-05T09:25:58Z")

</div>

- What is your evaluation of the proposal and its APIs/implementation?

+1

- Is the problem being addressed relevant for the wider Swift on Server ecosystem?

Multipart formdata is a common format used widely across the server ecosystem. Having a standard package for parsing it should be a target.

- Does this proposal fit well with the feel and direction of the Swift Server ecosystem?

Yes. Its uses `Codable` for encoding and decoding multipart form data

- How much effort did you put into your review? A glance, a quick reading, or an in-depth study?

I added a sample to the Hummingbird examples repository that demonstrated how to integrate it into a Hummingbird server. Integration was fairly easy. During this process I added a PR to make it easier to work with NIO `ByteBuffers`.

I have not looked into the internals of the system too much, as it just worked. I did notice it contains a large chunk of the swift-collections codebase and wondered whether that was necessary.

---

<div class="post-metadata">

**Author:** ![0xTim](https://sea2.discourse-cdn.com/swift/user_avatar/forums.swift.org/0xtim/32/27968_2.png) [@0xTim](https://forums.swift.org/u/0xTim)\
**Post date:** [October 5, 2021, 11:09am UTC](https://forums.swift.org/t/sswg-0017-multipartkit/52586/3 "2021-10-05T11:09:53Z")

</div>

> [@adam-fowler](#):
>
> I have not looked into the internals of the system too much, as it just worked. I did notice it contains a large chunk of the swift-collections codebase and wondered whether that was necessary.

We use it for storing the different boundaries IIRC (@siemensikkema can provide the actual reason). Now that Swift Collections is 1.0 we can pull it in as a dependency instead of copying the code - there's a [draft PR up](https://github.com/vapor/multipart-kit/pull/74) to do that.

\*_Note_: this would require us to bump the minimum supported Swift version of MultipartKit (and therefore Vapor) to 5.3 - I'm not adverse to this but might be worth a discussion

---

<div class="post-metadata">

**Author:** ![grahamburgsma](https://sea2.discourse-cdn.com/swift/user_avatar/forums.swift.org/grahamburgsma/32/5597_2.png) [@grahamburgsma](https://forums.swift.org/u/grahamburgsma)\
**Post date:** [October 5, 2021, 12:26pm UTC](https://forums.swift.org/t/sswg-0017-multipartkit/52586/4 "2021-10-05T12:26:04Z")

</div>

This is a question not a review, sorry if this is the wrong place.

I'm using MultipartKit to generate raw emails with attachments for use with AWS SES. Getting this to work required a lot of trial and error and I ended up having to customize the serialization to get it working correctly.

So is MIME encoding something that should/could be included in this library? When I was working on this, I couldn't find a Swift library that supported it. It seems having it in this library would be a logical place for it and I think it would be a valuable addition. Thanks!

---

<div class="post-metadata">

**Author:** ![siemensikkema](https://sea2.discourse-cdn.com/swift/user_avatar/forums.swift.org/siemensikkema/32/3768_2.png) [@siemensikkema](https://forums.swift.org/u/siemensikkema)\
**Post date:** [October 5, 2021, 2:47pm UTC](https://forums.swift.org/t/sswg-0017-multipartkit/52586/5 "2021-10-05T14:47:55Z")

</div>

Correct. It is included for OrderedDictionary which ensures a fixed order of the named parts when encoding. I would vote to drop 5.2 support if that means we can just depend on swift-collections.

---

<div class="post-metadata">

**Author:** ![adam-fowler](https://sea2.discourse-cdn.com/swift/user_avatar/forums.swift.org/adam-fowler/32/9266_2.png) [@adam-fowler](https://forums.swift.org/u/adam-fowler)\
**Post date:** [October 5, 2021, 3:02pm UTC](https://forums.swift.org/t/sswg-0017-multipartkit/52586/6 "2021-10-05T15:02:14Z")

</div>

> [@siemensikkema](#):
>
> I would vote to drop 5.2 support if that means we can just depend on swift-collections.

If swift-collections doesn't support swift 5.2 have you tested the code you extracted from swift-collections against swift 5.2?

---

<div class="post-metadata">

**Author:** ![siemensikkema](https://sea2.discourse-cdn.com/swift/user_avatar/forums.swift.org/siemensikkema/32/3768_2.png) [@siemensikkema](https://forums.swift.org/u/siemensikkema)\
**Post date:** [October 6, 2021, 6:34am UTC](https://forums.swift.org/t/sswg-0017-multipartkit/52586/7 "2021-10-06T06:34:31Z")

</div>

Yes, 5.2 is part of the test suite of MultipartKit. If there is any real incompatibility of swift-collections with Swift 5.2 then at least it is not in the part I extracted.

---

<div class="post-metadata">

**Author:** ![stephencelis](https://sea2.discourse-cdn.com/swift/user_avatar/forums.swift.org/stephencelis/32/2675_2.png) [@stephencelis](https://forums.swift.org/u/stephencelis)\
**Post date:** [October 6, 2021, 4:39pm UTC](https://forums.swift.org/t/sswg-0017-multipartkit/52586/8 "2021-10-06T16:39:12Z")

</div>

Such a library is definitely welcome! I do think the "nesting and collections" decoding/encoding is too rigidly bound to the Ruby on Rails convention. Other languages/frameworks out there use other encodings for nesting and collecting data, so ideally such a strategy would be customizable, similar to the strategies provided to `JSONDecoder` and `JSONEncoder`.

We built a URL form decoder a _long_ time ago and these were the strategies we supported:

> <https://github.com/pointfreeco/swift-web/blob/8cbec70d63206204eea3a036e536820dd767868c/Sources/UrlFormEncoding/UrlFormDecoder.swift#L573-L628>

Haven't visited the above code in awhile, but it'd be great for MultipartKit to support something similar!

---

<div class="post-metadata">

**Author:** ![siemensikkema](https://sea2.discourse-cdn.com/swift/user_avatar/forums.swift.org/siemensikkema/32/3768_2.png) [@siemensikkema](https://forums.swift.org/u/siemensikkema)\
**Post date:** [October 27, 2021, 12:22pm UTC](https://forums.swift.org/t/sswg-0017-multipartkit/52586/9 "2021-10-27T12:22:51Z")

</div>

I agree that would be a welcome customisation option. Thanks for linking to that snippet. It explains the scenarios very clearly.  
The transition to the "RoR convention" was actually a relatively recent change when we were made aware of the limitations of the other approach. Adding the ability to choose a strategy should be a non-breaking change we can introduce later on.

---

<div class="post-metadata">

**Author:** ![kmahar](https://sea2.discourse-cdn.com/swift/user_avatar/forums.swift.org/kmahar/32/5380_2.png) [@kmahar](https://forums.swift.org/u/kmahar)\
**Post date:** [November 10, 2021, 5:29pm UTC](https://forums.swift.org/t/sswg-0017-multipartkit/52586/10 "2021-11-10T17:29:53Z")

</div>

Thank you very much, everyone, for your participation in this thread!

I am pleased to announce that the SSWG has voted to accept MultipartKit at Incubating level.

@tomerd will lock this thread and add the package to the SSWG package index.
