我上传图片有一个奇怪的问题以下代码适用于小图片,但是当我尝试上传大尺寸图片时如果失败并出现以下错误 413请求实体太大ginx / 1.6.0 我正在使用IIS 6/7的WCF .Net服务。
我正在使用以下方法创建图像的base 64字符串:
func getBase64StringFromImage(anImage: UIImage, enhanceUpto:CGFloat) -> String{
let imageData = UIImageJPEGRepresentation(anImage, enhanceUpto)
let base64String = imageData!.base64EncodedStringWithOptions(.Encoding64CharacterLineLength)
//print(base64String)
return base64String
}
然后是以下服务电话:
if aSenderImageView1.image != nil{
base64ImageString1 = sABase64ImagetoString.getBase64StringFromImage(aSenderImageView1.image!, enhanceUpto: 1.0)
}
if base64ImageString1.length > 0 {
finalParamDict = ["Attach":base64ImageString1,"FileName":"Image1.jpeg"]
}
finalParamDict["Email"] = self.emailTxtField.text!
finalParamDict["Mobile"] = mobileNo
finalParamDict["NameEn"] = Defaults["customerName"].string!
finalParamDict["POBox"] = self.addressTxtField.text!
finalParamDict["ID"] = customerQID
finalParamDict["ServiceID"] = serviceID
finalParamDict["VAL1"] = gender
Alamofire.request(.POST,serverUrl ,headers:serviceHeaders,parameters:finalParamDict, encoding:.JSON)
.responseJSON{
response in
if let JSON = response.result.value {
print("JSON: \(JSON)")
}
}
这是对大于1MB的较大图像的响应。
Optional(<html>
<head><title>413 Request Entity Too Large</title></head>
<body bgcolor="white">
<center><h1>413 Request Entity Too Large</h1></center>
<hr><center>nginx/1.6.0</center>
</body>
</html>
)