How can we upload multipart form data with nested JSON parameters in Swift?
问题 I need to upload an image to the server endpoint where the structure has to be as following: { "image": { "file": imageData }, "access_token": access_token } How can I send such a request using NSURLSession (or maybe even Alamofire or AFNetworking)? 回答1: You cannot just include binary image data in a JSON request. JSON requires text representation, so if you do this, you must convert it to string (e.g. base64 encoding), use that in the JSON, and then the server code would presumably convert