通过Box java sdk

时间:2016-05-31 11:31:31

标签: box-api box

我试图通过框Java SDK将新版本的文件上传到Box。 上传后我得到了这个例外。

  

com.box.sdk.BoxAPIException:无法完成关闭连接   Box API由于网络错误或因为流已经存在   关闭。在   com.box.sdk.BoxAPIResponse.disconnect(BoxAPIResponse.java:159)at at   com.box.sdk.BoxFile.uploadVersion(BoxFile.java:471)at   com.box.sdk.BoxFile.uploadVersion(BoxFile.java:440)at   com.box.sdk.BoxFile.uploadVersion(BoxFile.java:430)at   com.mstack.dig.store.box.Box.uploadData(Box.java:102)at   com.mstack.dig.service.UploadServiceImpl.uploadFiles(UploadServiceImpl.java:41)     在   com.mstack.dig.controller.UploadController.uploadIndices(UploadController.java:39)     at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)at   sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)     在   sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)     在java.lang.reflect.Method.invoke(Method.java:498)at   org.springframework.web.method.support.InvocableHandlerMethod.doInvoke(InvocableHandlerMethod.java:221)     在   org.springframework.web.method.support.InvocableHandlerMethod.invokeForRequest(InvocableHandlerMethod.java:136)     在   org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle(ServletInvocableHandlerMethod.java:110)     在   org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.invokeHandlerMethod(RequestMappingHandlerAdapter.java:817)     在   org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.handleInternal(RequestMappingHandlerAdapter.java:731)     在   org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter.handle(AbstractHandlerMethodAdapter.java:85)     在   org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:959)     在   org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:893)     在   org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:968)     在   org.springframework.web.servlet.FrameworkServlet.doPost(FrameworkServlet.java:870)     在javax.servlet.http.HttpServlet.service(HttpServlet.java:727)at   org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:844)     在javax.servlet.http.HttpServlet.service(HttpServlet.java:820)at   org.mortbay.jetty.servlet.ServletHolder.handle(ServletHolder.java:511)     在   org.mortbay.jetty.servlet.ServletHandler.handle(ServletHandler.java:390)     在   org.mortbay.jetty.security.SecurityHandler.handle(SecurityHandler.java:216)     在   org.mortbay.jetty.servlet.SessionHandler.handle(SessionHandler.java:182)     在   org.mortbay.jetty.handler.ContextHandler.handle(ContextHandler.java:765)     在   org.mortbay.jetty.webapp.WebAppContext.handle(WebAppContext.java:440)     在   org.mortbay.jetty.handler.ContextHandlerCollection.handle(ContextHandlerCollection.java:230)     在   org.mortbay.jetty.handler.HandlerCollection.handle(HandlerCollection.java:114)     在   org.mortbay.jetty.handler.HandlerWrapper.handle(HandlerWrapper.java:152)     在org.mortbay.jetty.Server.handle(Server.java:326)处   org.mortbay.jetty.HttpConnection.handleRequest(HttpConnection.java:542)     在   org.mortbay.jetty.HttpConnection $ RequestHandler.content(HttpConnection.java:943)     在org.mortbay.jetty.HttpParser.parseNext(HttpParser.java:756)at   org.mortbay.jetty.HttpParser.parseAvailable(HttpParser.java:212)at at   org.mortbay.jetty.HttpConnection.handle(HttpConnection.java:404)at at   org.mortbay.io.nio.SelectChannelEndPoint.run(SelectChannelEndPoint.java:410)     在   org.mortbay.thread.QueuedThreadPool $ PoolThread.run(QueuedThreadPool.java:582)   引起:java.io.IOException:流被关闭了   sun.net.www.protocol.http.HttpURLConnection $ HttpInputStream.ensureOpen(HttpURLConnection.java:3309)     在   sun.net.www.protocol.http.HttpURLConnection $ HttpInputStream.read(HttpURLConnection.java:3334)     在   sun.net.www.protocol.http.HttpURLConnection $ HttpInputStream.read(HttpURLConnection.java:3329)     在com.box.sdk.BoxAPIResponse.disconnect(BoxAPIResponse.java:149)     ......还有40多个

但我注意到该文件已成功上传为新版本。这是API的任何问题吗?

我使用的代码段: -

 byte[] bytes = multipartFile.getBytes();
 inputStream = new ByteArrayInputStream(bytes);
 boxFile = new BoxFile(api, fileId); 
 boxFile.uploadVersion(inputStream);

1 个答案:

答案 0 :(得分:0)

我没弄清楚为什么会这样。但即使在此异常之后,我的文件上传工作正常。所以我们可以忽略这一点并继续上传。