报错信息:
[DEBUG] 2019-11-02 15:10:44,816 com.aebiz.app.web.commons.interceptor.LogTimeInterceptor.afterCompletion(LogTimeInterceptor.java:43) - [GET ]URI=/open/api/store/course/getDictList 18ms
[DEBUG] 2019-11-02 15:10:49,731 com.aebiz.baseframework.cache.impl.lcache.CachePubSub.onPMessage(CachePubSub.java:15) - channel=LCache:shiro-activeSessionCache, msg=01840onqeej03q1pqrj2eeb23u:75mfgbjptoi3sosh3r4jamsbci
15:10:49.735 [lcache.pubsub] DEBUG net.sf.ehcache.store.disk.Segment - remove deleted nothing
[DEBUG] 2019-11-02 15:10:49,743 com.aebiz.baseframework.cache.impl.lcache.CachePubSub.onPMessage(CachePubSub.java:15) - channel=LCache:shiro-activeSessionCache, msg=01840onqeej03q1pqrj2eeb23u:75mfgbjptoi3sosh3r4jamsbci
15:10:49.743 [lcache.pubsub] DEBUG net.sf.ehcache.store.disk.Segment - remove deleted nothing
15:10:50.581 [QuartzScheduler_clusterScheduler-PC-20180317VMTS1572677783735_ClusterManager] DEBUG org.springframework.scheduling.quartz.LocalDataSourceJobStore - ClusterManager: Check-in complete.
15:10:52.774 [clusterScheduler_QuartzSchedulerThread] DEBUG org.quartz.core.QuartzSchedulerThread - batch acquisition of 0 triggers
15:10:52.915 [http-apr-8080-exec-4] DEBUG org.apache.shiro.web.servlet.SimpleCookie - Found 'meta.session.id' cookie value [33olbnj8lciu6o5eqgje7j661k]
java.io.IOException: recv package size -1 != 10
at com.aebiz.fastdfs.ProtoCommon.recvHeader(ProtoCommon.java:215)
at com.aebiz.fastdfs.ProtoCommon.recvPackage(ProtoCommon.java:251)
at com.aebiz.fastdfs.TrackerClient.getStoreStorage(TrackerClient.java:143)
at com.aebiz.fastdfs.StorageClient.newWritableStorageConnection(StorageClient.java:1938)
at com.aebiz.fastdfs.StorageClient.do_upload_file(StorageClient.java:703)
at com.aebiz.fastdfs.StorageClient.upload_file(StorageClient.java:208)
at com.aebiz.fastdfs.StorageClient.upload_file(StorageClient.java:226)
at com.aebiz.fastdfs.StorageClient1.upload_file1(StorageClient1.java:112)
at com.aebiz.app.web.modules.controllers.open.api.file.UploadController.image(UploadController.java:136)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.springframework.web.method.support.InvocableHandlerMethod.doInvoke(InvocableHandlerMethod.java:205)
at org.springframework.web.method.support.InvocableHandlerMethod.invokeForRequest(InvocableHandlerMethod.java:133)
at org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle(ServletInvocableHandlerMethod.java:116)
at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.invokeHandlerMethod(RequestMappingHandlerAdapter.java:827)
at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.handleInternal(RequestMappingHandlerAdapter.java:738)
at org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter.handle(AbstractHandlerMethodAdapter.java:85)
at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:963)
at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:897)
at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:970)
at org.springframework.web.servlet.FrameworkServlet.doPost(FrameworkServlet.java:872)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:648)
at org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:846)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:729)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:292)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:207)
at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:240)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:207)
at com.thetransactioncompany.cors.CORSFilter.doFilter(CORSFilter.java:198)
at com.thetransactioncompany.cors.CORSFilter.doFilter(CORSFilter.java:244)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:240)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:207)
at org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:197)
[DEBUG] 2019-11-02 15:10:52,977 com.aebiz.app.web.commons.interceptor.LogTimeInterceptor.afterCompletion(LogTimeInterceptor.java:43) - [POST]URI=/open/api/file/upload 49ms
at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:240)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:207)
at com.aebiz.app.web.commons.filter.RouteFilter.doFilter(RouteFilter.java:33)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:240)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:207)
at org.apache.shiro.web.servlet.ProxiedFilterChain.doFilter(ProxiedFilterChain.java:61)
at org.apache.shiro.web.servlet.AdviceFilter.executeChain(AdviceFilter.java:108)
at org.apache.shiro.web.servlet.AdviceFilter.doFilterInternal(AdviceFilter.java:137)
at org.apache.shiro.web.servlet.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:125)
at org.apache.shiro.web.servlet.ProxiedFilterChain.doFilter(ProxiedFilterChain.java:66)
at org.apache.shiro.web.servlet.AbstractShiroFilter.executeChain(AbstractShiroFilter.java:449)
at org.apache.shiro.web.servlet.AbstractShiroFilter$1.call(AbstractShiroFilter.java:365)
at org.apache.shiro.subject.support.SubjectCallable.doCall(SubjectCallable.java:90)
at org.apache.shiro.subject.support.SubjectCallable.call(SubjectCallable.java:83)
at org.apache.shiro.subject.support.DelegatingSubject.execute(DelegatingSubject.java:383)
at org.apache.shiro.web.servlet.AbstractShiroFilter.doFilterInternal(AbstractShiroFilter.java:362)
at org.apache.shiro.web.servlet.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:125)
at org.springframework.web.filter.DelegatingFilterProxy.invokeDelegate(DelegatingFilterProxy.java:346)
at org.springframework.web.filter.DelegatingFilterProxy.doFilter(DelegatingFilterProxy.java:262)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:240)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:207)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:212)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:106)
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:502)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:141)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:79)
at org.apache.catalina.valves.AbstractAccessLogValve.invoke(AbstractAccessLogValve.java:616)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:88)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:528)
at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1099)
at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:670)
at org.apache.tomcat.util.net.AprEndpoint$SocketProcessor.doRun(AprEndpoint.java:2508)
at org.apache.tomcat.util.net.AprEndpoint$SocketProcessor.run(AprEndpoint.java:2497)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
at java.lang.Thread.run(Thread.java:748)
代码:
这一行:String fileId = client.upload_file1(fileBuff, fileExtName, metaList); 报错
@RequestMapping(value = "/upload", method = RequestMethod.POST)
@SJson
public Object image(@RequestParam("file") MultipartFile tf,
@RequestParam(value = "type", required = false) String type,
HttpServletRequest request, Model model) {
if (!tf.isEmpty()) {
List<String> imageList = config.getList("upload.suffix.file", ",");
if (imageList.contains(tf.getOriginalFilename().substring(tf.getOriginalFilename().lastIndexOf(".") + 1))) {
TrackerServer trackerServer = null;
TrackerClient tracker = null;
StorageServer storageServer = null;
try {
String uploadMode = config.get("upload.mode", "file");
if ("fdfs".equalsIgnoreCase(uploadMode)) {
//如果使用文件服务器
String fileName = tf.getOriginalFilename();
String fileExtName = fileName.substring(fileName.lastIndexOf(".") + 1);
byte[] fileBuff = tf.getBytes();
ClientGlobal.init(config);
//建立连接
tracker = new TrackerClient();
trackerServer = tracker.getConnection();
StorageClient1 client = new StorageClient1(trackerServer, storageServer);
//设置元信息
String fileLength = String.valueOf(tf.getSize());
NameValuePair[] metaList = new NameValuePair[3];
metaList[0] = new NameValuePair("fileName", fileName);
metaList[1] = new NameValuePair("fileExtName", fileExtName);
metaList[2] = new NameValuePair("fileLength", fileLength);
//上传文件
String fileId = client.upload_file1(fileBuff, fileExtName, metaList);
File file = nutFilePool.createFile("." + fileExtName);
Files.write(file, fileBuff);
//
Sys_att att = new Sys_att();
att.setName(fileName);
att.setFileSize(tf.getSize());
att.setFileExt(fileExtName);
att.setPath(fileId);
att.setType(type);
sysAttService.insert(att);
String url = "";
if ("knowledge".equals(type)) {
url = MessageFormat.format(this.knowledgeDownloadUrl, att.getId());
}else{
url = MessageFormat.format(this.attUrl, att.getId());
}
att.setUrl(url);
sysAttService.updateIgnoreNull(att);
this.addFileView(request,model,url,fileExtName);
return Result.success("globals.upload.success", att);
} else {
return Result.error("globals.upload.error");
}
} catch (Exception e) {
e.printStackTrace();
return Result.error("globals.upload.error");
} finally {
try {
if (trackerServer != null) {
trackerServer.close();
}
} catch (Exception e) {
}
}
} else {
return Result.error("globals.upload.suffix");
}
}
return Result.error("globals.upload.fail");
}