freshOS / ws-deprecated

⚠️ Deprecated - (in favour of Networking) :cloud: Elegantly connect to a JSON api. (Alamofire + Promises + JSON Parsing)
MIT License
353 stars 32 forks source link

POST form-urlencoded and form-data support? #28

Closed theabhishek2511 closed 7 years ago

theabhishek2511 commented 7 years ago

can't seem to figure out if these are supported or not at the moment. can ws do these?

s4cha commented 7 years ago

Hi @theabhishek2511,

Yes indeed :) Content-Type: application/x-www-form-urlencoded is the default for requests.

For instance

ws.post(“discussion/1234/messages”, params: ["message": "Hello there"])

Concerning Content-Type: multipart/form-data useful for uploading files, look for the multipart version like so :

ws.postMultipart("/upload/avatar", params: ["foo": "bar"], name: "file", data: data, fileName: "photo.jpg", mimeType: "image/jpeg")

Hope it helps ;)

theabhishek2511 commented 7 years ago

Thank you!