标签:str new ring mapping app ppi byte body mvc
@RestController
public class QiNiuController {
private static final Logger logger = LoggerFactory.getLogger(QiNiuController.class);
@Autowired
QiNiuServiceImpl qiNiuServiceImpl;
/**
* 将spring mvc接收到的图片再上传到七牛上
* @param file
* @param request
* @param response
* @param session
* @return
*/
@ResponseBody
@RequestMapping(value = "/photoUpload", method = RequestMethod.POST)
public String photoUpload(MultipartFile file, HttpServletRequest request, HttpServletResponse response,
HttpSession session) {
String resultURL;
if(null == file){
throw new BusinessException("图片不能为空");
}
try {
resultURL = qiNiuServiceImpl.upload2QiNiu(file);
} catch (IOException e) {
logger.error("图片file转换bytes错误",e);
throw new BusinessException("图片file转换bytes错误");
}
return resultURL;
}
}
标签:str new ring mapping app ppi byte body mvc
原文地址:http://www.cnblogs.com/panxuejun/p/7469631.html