七牛上传成功回调失败,没有进入回调服务器(java)。
java代码:
public String getUpToken(){
return auth.uploadToken(bucketName,null,3600,new StringMap()
.put("callbackUrl","http://159l42c091.imwork.net:15871/cczpt/imgController/callBack.xtm")
.put("callbackBody", "key='e666c70b-e78e-4eac-bacb-2750563882e2.png'&fsize=$(fsize)&mimeType=$(mimeType)"));
}
Response res = uploadManager.put("D:/filebank/bankCard/2016/10/9/e666c70b-e78e-4eac-bacb-2750563882e2.png", null, getUpToken());
回调服务器代码:
@RequestMapping("/callBack")
@ResponseBody
public void callBack(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
response.setContentType("text/html");
PrintWriter out = response.getWriter();
//接收七牛回调过来的内容
String line="";
BufferedReader br=new BufferedReader(new InputStreamReader(request.getInputStream()));
StringBuilder sb = new StringBuilder();
while((line = br.readLine())!=null){
sb.append(line);
}
System.out.println("水电费水电费水电费水电费水电费收到"+sb);//打印回调内容
//设置返回给七牛的json格式的数据
JSONObject json=new JSONObject();
json.put("response", "success");
out.println(json.toString());
out.flush();
out.close();
}
错误信息:
{"error":"{\"callback_url\":\"http://159l42c091.imwork.net:15871/cczpt/imgController/callBack.xtm\",\"callback_bodyType\":\"application/x-www-form-urlencoded\",\"callback_body\":\"key='e666c70b-e78e-4eac-bacb-2750563882e2.png'\\u0026fsize=26905\\u0026mimeType=image%2Fpng\",\"token\":\"\",\"err_code\":200,\"error\":\"unexpected response\",\"hash\":\"Fhuouc6HtvEIPIzQlWDGPeUiZCR7\",\"key\":\"Fhuouc6HtvEIPIzQlWDGPeUiZCR7\"}"}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论