flowapp / multipart_data_builder

MultipartDataBuilder is a micro framework for creating multipart data forms.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Multipart Data Builder

Build Status CocoaPods Compatible Carthage Compatible

MultipartDataBuilder is a micro framework for creating multipart data forms, used for uploading files over HTTP.

Usage

MultipartDataBuilder provides a simple API for building fields, and an extension on NSMutableURLRequest for attaching the built form and sets the required header.

Creating the multipart form:

var builder = MultipartDataBuilder()

Posting a file:

builder.appendFormData("image",
  content: image,
  fileName: "photo.jpg",
  contentType: "image/jpeg")

Adding other form data:

builder.appendFormData("filter", value: "sepia")

Building the form:

request.setMultipartBody(builder.build(), boundary: builder.boundary)

Install

  1. Add github "mogstad/multipart_data_builder" ~> 2.0 to your “Cartfile”
  2. Run carthage update
  3. Link MultipartDataBuilder with your target
  4. Create a new “Copy files” build phases, set ”Destination” to ”Frameworks”, add MultipartDataBuilder

Update your podfile:

  1. Add use_frameworks! to your pod file1
  2. Add pod "MultipartDataBuilder", "~> 2.0" to your target
  3. 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.

Footnotes

About

MultipartDataBuilder is a micro framework for creating multipart data forms.

License:MIT License


Languages

Language:Swift 86.2%Language:Ruby 10.6%Language:Objective-C 3.1%