Latest 3.0.0-alpha3
Homepage https://github.com/mogstad/multipart_data_builder
License MIT
Platforms ios 9.0, requires ARC
Dependencies libCommonCrypto
Authors

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

Carthage

  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

CocoaPods

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

  1. 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. 

Latest podspec

{
    "name": "MultipartDataBuilder",
    "version": "3.0.0-alpha3",
    "license": "MIT",
    "summary": "Micro framework for creating multipart forms",
    "homepage": "https://github.com/mogstad/multipart_data_builder",
    "authors": {
        "Bjarne Mogstad": "[email protected]"
    },
    "source": {
        "git": "https://github.com/mogstad/multipart_data_builder.git",
        "tag": "v3.0.0-alpha3"
    },
    "platforms": {
        "ios": "9.0"
    },
    "ios": {
        "frameworks": "MobileCoreServices"
    },
    "dependencies": {
        "libCommonCrypto": [
            "~> 0.1"
        ]
    },
    "source_files": [
        "sources/**/*.swift",
        "supporting_files/MultipartDataBuilder.h"
    ],
    "requires_arc": true
}

Pin It on Pinterest

Share This