swift - Uploading image to third party service using alamofire and auth token -


i have been trying upload image third party website using api , alamofire information regarding image has been uploaded. have pass auth token in request access resources, here instruction have provided,

"image should specified url or uploaded multipart form parameter 'data'. should use, respectively, , post methods."

i have been trying implement upload method in 5 different ways none of them seem work responseserializationfailed(alamofire.aferror.responseserializationfailurereason.jsonserializationfailed(error domain=nscocoaerrordomain code=3840 \"invalid value around character 2.\" userinfo={nsdebugdescription=invalid value around character 2.}))" error here 1 of functions takes care of upload:

    let headers: httpheaders = [ "authorization": "bearer \(authtoken)" ]     let url = try! urlrequest(url: "url", method: .post, headers: headers)      alamofire.upload(multipartformdata: { multipartformdata in         multipartformdata.append(imagedata, withname: "signimg", filename: "picture.png", mimetype: "image/png")     }, with: url, encodingcompletion: {         encodingresult in         switch encodingresult {         case .success(let upload, _, _):             upload.responsejson { response in                 debugprint("success response: \(response)")             }         case .failure(let encodingerror):             // hide progressbas here             print("error response: \(encodingerror)")         }     }) 

i don't understand meaning of parameters used append multipartformdata such withname, filetype, mimetype. appreciate if attach explanation solution.


Comments

Popular posts from this blog

ios - MKAnnotationView layer is not of expected type: MKLayer -

ZeroMQ on Windows, with Qt Creator -

unity3d - Unity SceneManager.LoadScene quits application -