Just icon indicating copy to clipboard operation
Just copied to clipboard

multipart / form-data

Open amervelic opened this issue 8 years ago • 2 comments

How to send ( post ) multipart / form-data? only string data ... not files ... Thanks ...

amervelic avatar Jan 05 '17 19:01 amervelic

You can use the text option of files.

Just.post("url", files: [.text(YOUR_TEXT, "filename", nil)])

dduan avatar Jan 05 '17 19:01 dduan

if let requestData = requestBody { body = requestData } else if files.count > 0 { body = synthesizeMultipartBody(data, files: files) let bound = self.defaults.multipartBoundary contentType = "multipart/form-data; boundary=(bound)"

.etc ...

This piece of code is not good - because it assumes that the "multipart" (as a string only) can not be a parameter. The specification says it can.       Content-Type: multipart / form-data; boundary = Aaxxxxx    Content-Disposition: form-data; name = "years" (no filename parameter)      20 - THIS IS VALUE    I changed the part of the code for my needs

amervelic avatar Jan 05 '17 21:01 amervelic