I'm actually trying to upload image to Imgur using its API.
I followed a tutorial and when it talks about the HttpBody tells to do something like
request.addValue("multipart/form-data; boundary=&", forHTTPHeaderField: "Content-Type")
var body = ""
body += "--&\r\n"
body += "Content-Disposition:form-data; name=\"image\""
body += "\r\n\r\n\(base64Image ?? "")\r\n"
body += "--&)--\r\n"
let postData = body.data(using: .utf8)
request.httpBody = postData
Which works perfectly fine but I don't understand how to add other
variables to the body which is why after browsing on different
StackOverflow questions I tried to do something on my own by setting the
boundary as '&' and then just tried to do the following:
let bodyData = "image=\(base64Image ?? "")"
request.httpBody = bodyData.data(using: .utf8)
But I always end-up having server errors and I don't understand what I am doing wrong
Any help could be appreciated
Post
Replies
Boosts
Views
Activity
Hi,
I just started learning Swift for school projects, I installed XCode 12 on the App Store but now on the tutorials I'm trying to follow they tell me to create a "Single View Application" but on the different templates I have there is no Single View Application.
I tried to chose other templates but when I do that I don't have the same files as the one in the tutorial.
I've tried to look on Internet about single view application for XCode 12 and Swift 5 but didn't find anything.
How can I create a Single View Application with this configuration ?