The missing multipart form support for URLSession.
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
Sources/MultipartForm
Tests
.gitignore
LICENSE
MultipartForm.podspec
Package.swift
README.md

README.md

MultipartForm

A simple way to create multipart form requests in Swift.

Example

import MultipartForm

let form = MultipartForm(parts: [
	MultipartForm.Part(name: "a", value: "1"),
	MultipartForm.Part(name: "b", value: "2"),
	MultipartForm.Part(name: "c", data: imageData, filename: "3.png", contentType: "image/png"),
])

var request = URLRequest(url: url)
request.httpMethod = "POST"
request.setValue(form.contentType, forHTTPHeaderField: "Content-Type")

let task = session.uploadTask(with: request, from: form.bodyData)
task.resume()