layim.config({
//上传图片接口
,uploadImage: {url: '/upload/file'}
//上传文件接口
,uploadFile: {url: '/upload/file'}
//其他代码
})
{"code":0,"msg":"success","data":{"src":"/upload/d8740baa-cf7e-497c-a085-5c6ed9633f35.gif","name":"8.gif"}}
/**
* 上传文件的路径配置
* */
@Value("${layim.upload.dir}")
private String fileDirPath;
private final ResourceLoader resourceLoader;
@Autowired
public UploadController(ResourceLoader resourceLoader){
this.resourceLoader = resourceLoader;
}
/**
* 访问文件路径,使用resourceLoader获取文件
* */
@GetMapping(value = "/{filename:.+}")
@ResponseBody
public ResponseEntity<?> getFile(@PathVariable String filename) {
try {
String location = "file:"+ Paths.get(fileDirPath, filename).toString();
Resource resource = resourceLoader.getResource(location);
return ResponseEntity.ok(resource);
} catch (Exception e) {
return ResponseEntity.notFound().build();
}
}
http: multipart: max-file-size: 30MB max-request-size: 30MB
@Override
public Resource getResource(String location) {
Assert.notNull(location, "Location must not be null");
for (ProtocolResolver protocolResolver : this.protocolResolvers) {
Resource resource = protocolResolver.resolve(location, this);
if (resource != null) {
return resource;
}
}
//我们是使用file:开头的
if (location.startsWith("/")) {
return getResourceByPath(location);
}
//这里判断是不是走 classpath:
else if (location.startsWith(CLASSPATH_URL_PREFIX)) {
return new ClassPathResource(location.substring(CLASSPATH_URL_PREFIX.length()), getClassLoader());
}
else {
try {
//最后将文件地址转化成了url
// Try to parse the location as a URL...
URL url = new URL(location);
return new UrlResource(url);
}
catch (MalformedURLException ex) {
// No URL -> resolve as resource path.
return getResourceByPath(location);
}
}
}
//监听天窗口的切换
layim.on('chatChange', function(res){
console.log(res.data);
});
var t = res.data.type=='friend';
socket.send({
mtype:t? socket.mtype.checkIsOnline:socket.mtype.checkOnlineCount,
id:res.data.id
});
ChannelContext checkChannelContext = Aio.getChannelContextByUserid(channelContext.getGroupContext(),body.getId()); //检查是否在线 boolean isOnline = checkChannelContext != null && !checkChannelContext.isClosed();
SetWithLock<ChannelContext> channelLocks = Aio.getChannelContextsByGroup(channelContext.getGroupContext(),body.getId()); int onlineCount = channelLocks.getObj().size();
机械节能产品生产企业官网模板...
大气智能家居家具装修装饰类企业通用网站模板...
礼品公司网站模板
宽屏简约大气婚纱摄影影楼模板...
蓝白WAP手机综合医院类整站源码(独立后台)...苏ICP备2024110244号-2 苏公网安备32050702011978号 增值电信业务经营许可证编号:苏B2-20251499 | Copyright 2018 - 2025 源码网商城 (www.ymwmall.com) 版权所有