MultipartDataBuilder is a micro framework for creating multipart data forms, used for uploading files over HTTP.
MultipartDataBuilder provides a simple API for building fields, and an extension on NSMutableURLRequest
for attaching the built form and sets the required header.
var builder = MultipartDataBuilder()
builder.appendFormData("image",
content: image,
fileName: "photo.jpg",
contentType: "image/jpeg")
builder.appendFormData("filter", value: "sepia")
request.setMultipartBody(builder.build(), boundary: builder.boundary)
- Add
github "mogstad/multipart_data_builder" ~> 2.0
to your “Cartfile” - Run
carthage update
- Link MultipartDataBuilder with your target
- Create a new “Copy files” build phases, set ”Destination” to ”Frameworks”, add MultipartDataBuilder
Update your podfile:
- Add
use_frameworks!
to your pod file1 - Add
pod "MultipartDataBuilder", "~> 2.0"
to your target - Update your dependencies by running
pod install
Swift code can’t be included as a static library, therefor it’s required to add use_frameworks!
to your podfile
. It will then import your dependeices as dynamic frameworks.