This is how i simply upload images to Imgur using Alamofire and Swift:
let url = URL(string: "https://api.imgur.com/3/upload")!
private var headers: [String: String] {
["X-Token": "[mytokenhere]", "Authorization": "Client-ID [myidhere]"]
}
Alamofire.upload(multipartFormData: { multipart in
if let data = UIImagePNGRepresentation(image.image) {
multipart.append(data, withName: "image", fileName: "image.png", mimeType: "image/png")
}
}, to: url, headers: headers, encodingCompletion: { result in
//convert result image from result here
})
Example before upload, original image (as you can see, it adds white background even here on SO, why?):
and after upload, returned url to an uploaded image:
originally on computer and iphone it look like this:







