Ale*_*agó 5 networking base64 swift ios8 alamofire
我正在使用Swift中的Alamofire发送带有编码的base64图像的POST请求。
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)
}
Run Code Online (Sandbox Code Playgroud)
问题是我无法发送大型编码的base64图像,因为得到的响应为“ nil”。我知道我的服务器可以处理该请求,因为它可以在Chrome上使用Android或PostMan成功运行。
编码图像:
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
Run Code Online (Sandbox Code Playgroud)
有什么想法吗?
归档时间: |
|
查看次数: |
1044 次 |
最近记录: |