daltoniam / SwiftHTTP

Thin wrapper around NSURLSession in swift. Simplifies HTTP requests.
Apache License 2.0
1.88k stars 313 forks source link

Cannot upload file #294

Open LinusGeffarth opened 6 years ago

LinusGeffarth commented 6 years ago

Hey,
I'm trying to upload a file as follows:

guard let imageData = UIImageJPEGRepresentation(image) else { return }
let headers = ["Authorization": Data.accessToken, "Content-Type": "multipart/form-data", "Accept": "application/vnd.api+json"]
let parameters: [String: Any] = [
    "file": Upload(data: imageData, fileName: "img", mimeType: "image/jpeg")
]
HTTP.POST("my-url...", parameters: parameters, headers: headers, completionHandler: completion)

... but the backend doesn't receive the image.

May this be caused by the library? Does it work for anyone else?