Is there a restriction on POST request using Alamofire on iOS?

I am sending a POST request with a base64 encoded image using Alamofire in Swift.

let requestURL = NSURL(string: Constants.kBaseURL + method)!

let config = NSURLSessionConfiguration.defaultSessionConfiguration()
config.timeoutIntervalForResource = Constants.kNetworkTimeout

self.networkManager = Alamofire.Manager(configuration: config)

self.networkManager!.request(.POST, requestURL, parameters: parameters)
    .authenticate(user: Constants.kAPIUSER, password: Constants.kAPIKEY)
    .responseJSON(options: NSJSONReadingOptions.MutableContainers) { (_, _, JSON, _) -> Void in
        var result = RequestResultModel()
        let responseContent = self.checkContent(JSON, method: method)
        result.setResult(responseContent.0, message: responseContent.1, content: responseContent.2, method: method)
        callback!(result: result)
}

The problem is that I cannot send large base64 encoded images because I get a "zero" response. I know that my server can handle the request because it worked successfully with Android or PostMan in Chrome.

Image Encoding:

var imageData = UIImageJPEGRepresentation(utility.cropAndCenter(image, width: 500, height: 500), 70) <---- NOT WORKING
var imageData = UIImageJPEGRepresentation(utility.cropAndCenter(image, width: 100, height: 100), 70) <---- WORKING

Any idea what is going on?

+4
source share

Source: https://habr.com/ru/post/1588949/


All Articles