Merge pull request #3 from BradPatras/master Added support for mixed multipart content type
Merge pull request #3 from BradPatras/master
Added support for mixed multipart content type
A simple way to create multipart form requests in Swift.
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()
To upload a file in the background, you can write out form.bodyData to a file and create an upload task from that.
form.bodyData
©Copyright 2023 CCF 开源发展委员会 Powered by Trustie& IntelliDE 京ICP备13000930号
MultipartForm
A simple way to create multipart form requests in Swift.
Example
To upload a file in the background, you can write out
form.bodyData
to a file and create an upload task from that.