Norway


.upload(.POST, "(BASE_URL)addPurchase",  // Error: Error:   to  'upload(_:to:method:headers:)'
                         // define your headers here
            
            headers: ["Content-Type" : "multipart/form-","authorization": UserDefaults.standard.value(forKeyPath: "USERDETAILS.authToken")! as! String,"auth-id":"((UserDefaults.standard.value(forKeyPath: "USERDETAILS.customerId"))!)"],
            multipartFormData: { multipartFormData in
                
        
                // import image to request
                for i in 0..<self.arrItemPic.count
                {
                if let imageData = UIImageJPEGRepresentation(self.arrItemPic[i], 0.) {
                    multipartFormData.appendBodyPart(data: imageData, name: "image(i+1)", fileName: "img(i+1).png", mimeType: "image/png")
                }
            }
                // import parameters
                for (, value) in jsonDictionary {
                    multipartFormData.appendBodyPart(data: value.data(using: String.Encoding.utf8)!, name: )
                }
            }, // you can customise Threshold if you wish. This is the 's default value
            to: BASE_URL,
            encodingCompletion: { encodingResult in
               
                switch encodingResult {
                case .success(let upload, _, _):
                    upload.responseJSON { response in
                        print(response)
                        
                        if let result = response.result.value {
                            let JSON = result as! NSDictionary
                             hud.hide(animated: true)
                        showProgress.showToastWithMessage("Purchase added Successfully", andTheContainView: (self.navigationController?.view)!)
                            self.arrPurchaseDet = JSON.value(forKey: "data") as! NSMutableDictionary
                         self.gotoCarryforMe()
                        }
                    }
                case .failure(let encodingError):
                     hud.hide(animated: true)
                    if let err = encodingError as? URLError, err == .notConnectedToInternet {
                        
                    showProgress.showToastWithMessage("Server Error", andTheContainView: (self.navigationController?.view)!)
                    } else {
                        // other failures
                    }
                    print(encodingError)
                }
        })



Source link

LEAVE A REPLY

Please enter your comment!
Please enter your name here