获取 java.io.IOException:尝试将文件 XXXXXX 上传到路径 XXXXX,但那是一个目录。使用 net.schmizz.sshj.SSHClient 时

问题描述 投票:0回答:1

在对远程服务器执行 SFTP 时出现此异常

以下是异常的堆栈跟踪

java.io.IOException: Trying to upload file Test.pdf to path /MyFolder/NewTest/Test.pdf but that is a directory
    at net.schmizz.sshj.sftp.SFTPFileTransfer$Uploader.prepareFile(SFTPFileTransfer.java:310)
    at net.schmizz.sshj.sftp.SFTPFileTransfer$Uploader.uploadFile(SFTPFileTransfer.java:228)
    at net.schmizz.sshj.sftp.SFTPFileTransfer$Uploader.upload(SFTPFileTransfer.java:183)
    at net.schmizz.sshj.sftp.SFTPFileTransfer$Uploader.access$100(SFTPFileTransfer.java:166)
    at net.schmizz.sshj.sftp.SFTPFileTransfer.upload(SFTPFileTransfer.java:64)
    at net.schmizz.sshj.sftp.SFTPClient.put(SFTPClient.java:244)

以下是正在使用的代码片段

String localFile = "D:/SFTPFiles/Test.pdf";
String remoteFilePath = "/MyFolder/NewTest";

SSHClient sshClient = new SSHClient();
sshClient.addHostKeyVerifier(new PromiscuousVerifier());
sshClient.connect(remoteHost);
sshClient.authPassword(downloadUserName, password);
SFTPClient sftpClient = sshClient.newSFTPClient();
FileSystemFile fileSystemFile = new FileSystemFile(localFile);
sftpClient.put(fileSystemFile, remoteFilePath);
sftpClient.close();
sshClient.disconnect();

我已检查并确保本地服务器上的文件存在。远程服务器上的目录也存在。还尝试过使用 StatefulSFTPClient。远程服务器上也不存在与文件名同名的目录。

详细日志:

java.io.IOException: Trying to upload file Test.pdf to path MyFolder/NewTest/Test.pdf but that is a directory
    at net.schmizz.sshj.sftp.SFTPFileTransfer$Uploader.prepareFile(SFTPFileTransfer.java:310)
    at net.schmizz.sshj.sftp.SFTPFileTransfer$Uploader.uploadFile(SFTPFileTransfer.java:228)
    at net.schmizz.sshj.sftp.SFTPFileTransfer$Uploader.upload(SFTPFileTransfer.java:183)
    at net.schmizz.sshj.sftp.SFTPFileTransfer$Uploader.access$100(SFTPFileTransfer.java:166)
    at net.schmizz.sshj.sftp.SFTPFileTransfer.upload(SFTPFileTransfer.java:64)
    at net.schmizz.sshj.sftp.SFTPClient.put(SFTPClient.java:244)
    at com.testing.user.prjct.NYCServiceImpl.uploadFileToCBCKPA(NYCServiceImpl.java:241)
    at com.testing.user.prjct.NYCServiceImpl$$FastClassBySpringCGLIB$$c952ae3c.invoke(<generated>)
    at org.springframework.cglib.proxy.MethodProxy.invoke(MethodProxy.java:204)
    at org.springframework.aop.framework.CglibAopProxy$DynamicAdvisedInterceptor.intercept(CglibAopProxy.java:685)
    at com.testing.user.prjct.NYCServiceImpl$$EnhancerBySpringCGLIB$$b7522d71.uploadFileToCBCKPA(<generated>)
    at com.testing.user.prjct.NYCController.getProgressNYC(NYCController.java:66)
    at com.testing.user.prjct.NYCController$$FastClassBySpringCGLIB$$7a84daf5.invoke(<generated>)
    at org.springframework.cglib.proxy.MethodProxy.invoke(MethodProxy.java:204)
    at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.invokeJoinpoint(CglibAopProxy.java:747)
    at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:163)
    at org.springframework.validation.beanvalidation.MethodValidationInterceptor.invoke(MethodValidationInterceptor.java:112)
    at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:185)
    at org.springframework.aop.framework.CglibAopProxy$DynamicAdvisedInterceptor.intercept(CglibAopProxy.java:689)
    at com.testing.user.prjct.NYCController$$EnhancerBySpringCGLIB$$e05a8618.getProgressNYC(<generated>)
    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:209)
    at org.springframework.web.method.support.InvocableHandlerMethod.invokeForRequest(InvocableHandlerMethod.java:136)
    at org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle(ServletInvocableHandlerMethod.java:102)
    at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.invokeHandlerMethod(RequestMappingHandlerAdapter.java:870)
    at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.handleInternal(RequestMappingHandlerAdapter.java:776)
    at org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter.handle(AbstractHandlerMethodAdapter.java:87)
    at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:991)
    at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:925)
    at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:978)
    at org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:870)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:635)
    at org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:855)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:742)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:231)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
    at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
    at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:101)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
    at com.testing.commons.MyFilter.doFilterInternal(MyFilter.java:19)
    at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
    at org.springframework.boot.actuate.metrics.web.servlet.WebMvcMetricsFilter.filterAndRecordMetrics(WebMvcMetricsFilter.java:158)
    at org.springframework.boot.actuate.metrics.web.servlet.WebMvcMetricsFilter.filterAndRecordMetrics(WebMvcMetricsFilter.java:126)
    at org.springframework.boot.actuate.metrics.web.servlet.WebMvcMetricsFilter.doFilterInternal(WebMvcMetricsFilter.java:111)
    at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
    at org.springframework.boot.actuate.web.trace.servlet.HttpTraceFilter.doFilterInternal(HttpTraceFilter.java:84)
    at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
    at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:320)
    at org.springframework.security.web.access.intercept.FilterSecurityInterceptor.invoke(FilterSecurityInterceptor.java:127)
    at org.springframework.security.web.access.intercept.FilterSecurityInterceptor.doFilter(FilterSecurityInterceptor.java:91)
    at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334)
    at org.springframework.security.web.access.ExceptionTranslationFilter.doFilter(ExceptionTranslationFilter.java:119)
    at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334)
    at org.springframework.security.web.session.SessionManagementFilter.doFilter(SessionManagementFilter.java:137)
    at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334)
    at org.springframework.security.web.authentication.AnonymousAuthenticationFilter.doFilter(AnonymousAuthenticationFilter.java:111)
    at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334)
    at org.springframework.security.web.servletapi.SecurityContextHolderAwareRequestFilter.doFilter(SecurityContextHolderAwareRequestFilter.java:170)
    at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334)
    at org.springframework.security.web.savedrequest.RequestCacheAwareFilter.doFilter(RequestCacheAwareFilter.java:63)
    at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334)
    at com.testing.service.jwt.JwtAuthTokenFilter.doFilterInternal(JwtAuthTokenFilter.java:49)
    at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
    at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334)
    at org.springframework.security.web.authentication.logout.LogoutFilter.doFilter(LogoutFilter.java:116)
    at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334)
    at org.springframework.web.filter.CorsFilter.doFilterInternal(CorsFilter.java:96)
    at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
    at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334)
    at org.springframework.security.web.header.HeaderWriterFilter.doFilterInternal(HeaderWriterFilter.java:66)
    at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
    at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334)
    at org.springframework.security.web.context.SecurityContextPersistenceFilter.doFilter(SecurityContextPersistenceFilter.java:105)
    at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334)
    at org.springframework.security.web.context.request.async.WebAsyncManagerIntegrationFilter.doFilterInternal(WebAsyncManagerIntegrationFilter.java:56)
    at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
    at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334)
    at org.springframework.security.web.FilterChainProxy.doFilterInternal(FilterChainProxy.java:215)
    at org.springframework.security.web.FilterChainProxy.doFilter(FilterChainProxy.java:178)
    at org.springframework.web.filter.DelegatingFilterProxy.invokeDelegate(DelegatingFilterProxy.java:357)

对于没有这样的文件:

net.schmizz.sshj.sftp.SFTPException: No such file
    at net.schmizz.sshj.sftp.Response.error(Response.java:140)
    at net.schmizz.sshj.sftp.Response.ensurePacketTypeIs(Response.java:117)
    at net.schmizz.sshj.sftp.SFTPEngine.open(SFTPEngine.java:143)
    at net.schmizz.sshj.sftp.SFTPEngine.open(SFTPEngine.java:149)
    at net.schmizz.sshj.sftp.SFTPFileTransfer$Uploader.uploadFile(SFTPFileTransfer.java:233)
    at net.schmizz.sshj.sftp.SFTPFileTransfer$Uploader.upload(SFTPFileTransfer.java:183)
    at net.schmizz.sshj.sftp.SFTPFileTransfer$Uploader.access$100(SFTPFileTransfer.java:166)
    at net.schmizz.sshj.sftp.SFTPFileTransfer.upload(SFTPFileTransfer.java:64)
    at net.schmizz.sshj.sftp.SFTPClient.put(SFTPClient.java:244)
    at com.testing.user.prjct.NYCServiceImpl.uploadFileToCBCKPA(NYCServiceImpl.java:241)
    at com.testing.user.prjct.NYCServiceImpl$$FastClassBySpringCGLIB$$c952ae3c.invoke(<generated>)
    at org.springframework.cglib.proxy.MethodProxy.invoke(MethodProxy.java:204)
    at org.springframework.aop.framework.CglibAopProxy$DynamicAdvisedInterceptor.intercept(CglibAopProxy.java:685)
    at com.testing.user.prjct.NYCServiceImpl$$EnhancerBySpringCGLIB$$60abb72e.uploadFileToCBCKPA(<generated>)
    at com.testing.user.prjct.NYCController.getProgressNYC(NYCController.java:66)
    at com.testing.user.prjct.NYCController$$FastClassBySpringCGLIB$$7a84daf5.invoke(<generated>)
    at org.springframework.cglib.proxy.MethodProxy.invoke(MethodProxy.java:204)
    at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.invokeJoinpoint(CglibAopProxy.java:747)
    at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:163)
    at org.springframework.validation.beanvalidation.MethodValidationInterceptor.invoke(MethodValidationInterceptor.java:112)
    at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:185)
    at org.springframework.aop.framework.CglibAopProxy$DynamicAdvisedInterceptor.intercept(CglibAopProxy.java:689)
    at com.testing.user.prjct.NYCController$$EnhancerBySpringCGLIB$$1e621918.getProgressNYC(<generated>)
    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:209)
    at org.springframework.web.method.support.InvocableHandlerMethod.invokeForRequest(InvocableHandlerMethod.java:136)
    at org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle(ServletInvocableHandlerMethod.java:102)
    at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.invokeHandlerMethod(RequestMappingHandlerAdapter.java:870)
    at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.handleInternal(RequestMappingHandlerAdapter.java:776)
    at org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter.handle(AbstractHandlerMethodAdapter.java:87)
    at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:991)
    at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:925)
    at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:978)
    at org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:870)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:635)
    at org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:855)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:742)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:231)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
    at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)

WinScp 成功文件传输日志


. 2021-03-23 17:48:16.920 Session upkeep
. 2021-03-23 17:48:17.351 Getting current directory name.
. 2021-03-23 17:48:17.351 Listing directory "/MyFolder/NewTest".
> 2021-03-23 17:48:17.351 Type: SSH_FXP_OPENDIR, Size: 23, Number: 1547
. 2021-03-23 17:48:17.351 Sent 27 bytes
. 2021-03-23 17:48:17.352 There are 0 bytes remaining in the send buffer
. 2021-03-23 17:48:17.352 Read 4 bytes (24 pending)
. 2021-03-23 17:48:17.352 Read 24 bytes (0 pending)
< 2021-03-23 17:48:17.352 Type: SSH_FXP_STATUS, Size: 24, Number: 1284
. 2021-03-23 17:48:17.352 Discarding reserved response
. 2021-03-23 17:48:17.352 Waiting for another 4 bytes
. 2021-03-23 17:48:17.363 Detected network event
. 2021-03-23 17:48:17.363 Waiting for another 4 bytes
. 2021-03-23 17:48:17.363 Received 14 bytes
. 2021-03-23 17:48:17.363 Read 4 bytes (10 pending)
. 2021-03-23 17:48:17.363 Read 10 bytes (0 pending)
< 2021-03-23 17:48:17.363 Type: SSH_FXP_HANDLE, Size: 10, Number: 1547
> 2021-03-23 17:48:17.363 Type: SSH_FXP_READDIR, Size: 10, Number: 1804
. 2021-03-23 17:48:17.363 Sent 14 bytes
. 2021-03-23 17:48:17.363 There are 0 bytes remaining in the send buffer
. 2021-03-23 17:48:17.363 Waiting for another 4 bytes
. 2021-03-23 17:48:17.372 Detected network event
. 2021-03-23 17:48:17.373 Waiting for another 4 bytes
. 2021-03-23 17:48:17.373 Received 227 bytes
. 2021-03-23 17:48:17.373 Read 4 bytes (223 pending)
. 2021-03-23 17:48:17.373 Read 223 bytes (0 pending)
< 2021-03-23 17:48:17.373 Type: SSH_FXP_NAME, Size: 223, Number: 1804
> 2021-03-23 17:48:17.373 Type: SSH_FXP_READDIR, Size: 10, Number: 2060
. 2021-03-23 17:48:17.373 Sent 14 bytes
. 2021-03-23 17:48:17.373 There are 0 bytes remaining in the send buffer
. 2021-03-23 17:48:17.373 Read file 'panImage.jpg' from listing
. 2021-03-23 17:48:17.373 Read file 'TEST.pdf' from listing
. 2021-03-23 17:48:17.373 Waiting for another 4 bytes
. 2021-03-23 17:48:17.383 Detected network event
. 2021-03-23 17:48:17.383 Waiting for another 4 bytes
. 2021-03-23 17:48:17.383 Received 32 bytes
. 2021-03-23 17:48:17.383 Read 4 bytes (28 pending)
. 2021-03-23 17:48:17.383 Read 28 bytes (0 pending)
< 2021-03-23 17:48:17.383 Type: SSH_FXP_STATUS, Size: 28, Number: 2060
< 2021-03-23 17:48:17.383 Status code: 1
> 2021-03-23 17:48:17.383 Type: SSH_FXP_CLOSE, Size: 10, Number: 2308
. 2021-03-23 17:48:17.383 Sent 14 bytes
. 2021-03-23 17:48:17.383 There are 0 bytes remaining in the send buffer
. 2021-03-23 17:48:17.383 panImage.jpg;-;926778;2021-03-22T13:28:50.000Z;3;"user" [0];"group" [0];-w--w--w-;1
. 2021-03-23 17:48:17.383 TEST.pdf;-;1057344;2021-03-22T13:35:46.000Z;3;"user" [0];"group" [0];-w--w--w-;1
. 2021-03-23 17:48:17.384 ..;D;0;1899-12-30T05:30:00.000Z;0;"" [0];"" [0];---------;0
. 2021-03-23 17:48:17.608 Session upkeep

. 2021-03-23 17:48:18.457 Session upkeep
. 2021-03-23 17:48:18.457 Detected network event
. 2021-03-23 17:48:18.970 Session upkeep
. 2021-03-23 17:48:19.485 Session upkeep
. 2021-03-23 17:48:19.985 Session upkeep
. 2021-03-23 17:48:20.499 Session upkeep
. 2021-03-23 17:48:20.499 Received 28 bytes
. 2021-03-23 17:48:20.999 Session upkeep

. 2021-03-23 17:48:26.541 Session upkeep
. 2021-03-23 17:48:27.040 Session upkeep
. 2021-03-23 17:48:27.177 Size of 1 local files/folders calculated as 11
. 2021-03-23 17:48:27.218 Copying 1 files/directories to remote directory "/MyFolder/NewTest/" - total size: 11
. 2021-03-23 17:48:27.218   PrTime: Yes; PrRO: No; Rght: rw-r--r--; PrR: No (No); FnCs: N; RIC: 0100; Resume: S (102400); CalcS: Yes; Mask: *.*
. 2021-03-23 17:48:27.218   TM: B; ClAr: No; RemEOF: No; RemBOM: No; CPS: 0; NewerOnly: No; EncryptNewFiles: Yes; ExcludeHiddenFiles: No; ExcludeEmptyDirectories: No; InclM: ; ResumeL: 0
. 2021-03-23 17:48:27.218   AscM: *.*html; *.htm; *.txt; *.php; *.php3; *.cgi; *.c; *.cpp; *.h; *.pas; *.bas; *.tex; *.pl; *.js; .htaccess; *.xtml; *.css; *.cfg; *.ini; *.sh; *.xml
. 2021-03-23 17:48:27.221 File: 'D:\Work\kyc\Test2.txt' [2021-03-23T09:42:55.891Z] [11]
. 2021-03-23 17:48:27.221 Copying "D:\Work\kyc\Test2.txt" to remote directory started.
. 2021-03-23 17:48:27.221 Binary transfer mode selected.
. 2021-03-23 17:48:27.221 Opening remote file.
> 2021-03-23 17:48:27.221 Type: SSH_FXP_OPEN, Size: 49, Number: 2563
. 2021-03-23 17:48:27.221 Sent 53 bytes
. 2021-03-23 17:48:27.222 There are 0 bytes remaining in the send buffer
. 2021-03-23 17:48:27.222 Read 4 bytes (24 pending)
. 2021-03-23 17:48:27.222 Read 24 bytes (0 pending)
< 2021-03-23 17:48:27.222 Type: SSH_FXP_STATUS, Size: 24, Number: 2308
. 2021-03-23 17:48:27.222 Discarding reserved response
. 2021-03-23 17:48:27.222 Waiting for another 4 bytes
. 2021-03-23 17:48:27.239 Detected network event
. 2021-03-23 17:48:27.239 Waiting for another 4 bytes
. 2021-03-23 17:48:27.240 Received 14 bytes
. 2021-03-23 17:48:27.240 Read 4 bytes (10 pending)
. 2021-03-23 17:48:27.240 Read 10 bytes (0 pending)
< 2021-03-23 17:48:27.240 Type: SSH_FXP_HANDLE, Size: 10, Number: 2563
. 2021-03-23 17:48:27.586 Write request offset: 0, len: 11
> 2021-03-23 17:48:27.587 Type: SSH_FXP_WRITE, Size: 33, Number: 3078
. 2021-03-23 17:48:27.587 Sent 37 bytes
. 2021-03-23 17:48:27.587 There are 0 bytes remaining in the send buffer
> 2021-03-23 17:48:27.587 Type: SSH_FXP_CLOSE, Size: 10, Number: 3332
. 2021-03-23 17:48:27.587 Sent 14 bytes
. 2021-03-23 17:48:27.587 There are 0 bytes remaining in the send buffer
> 2021-03-23 17:48:27.587 Type: SSH_FXP_SETSTAT, Size: 45, Number: 2825
. 2021-03-23 17:48:27.587 Sent 49 bytes
. 2021-03-23 17:48:27.587 There are 0 bytes remaining in the send buffer
. 2021-03-23 17:48:27.587 Waiting for another 4 bytes
. 2021-03-23 17:48:27.604 Detected network event
. 2021-03-23 17:48:27.604 Waiting for another 4 bytes
. 2021-03-23 17:48:27.604 Received 56 bytes
. 2021-03-23 17:48:27.604 Read 4 bytes (52 pending)
. 2021-03-23 17:48:27.604 Read 24 bytes (28 pending)
< 2021-03-23 17:48:27.604 Type: SSH_FXP_STATUS, Size: 24, Number: 3078
< 2021-03-23 17:48:27.604 Status code: 0
. 2021-03-23 17:48:27.605 Read 4 bytes (24 pending)
. 2021-03-23 17:48:27.605 Read 24 bytes (0 pending)
< 2021-03-23 17:48:27.605 Type: SSH_FXP_STATUS, Size: 24, Number: 3332
< 2021-03-23 17:48:27.605 Status code: 0
. 2021-03-23 17:48:27.605 Preserving timestamp [2021-03-23T09:42:55.000Z]
. 2021-03-23 17:48:27.605 Waiting for another 4 bytes
. 2021-03-23 17:48:27.621 Detected network event
. 2021-03-23 17:48:27.621 Waiting for another 4 bytes
. 2021-03-23 17:48:27.621 Received 28 bytes
. 2021-03-23 17:48:27.621 Read 4 bytes (24 pending)
. 2021-03-23 17:48:27.621 Read 24 bytes (0 pending)
< 2021-03-23 17:48:27.621 Type: SSH_FXP_STATUS, Size: 24, Number: 2825
< 2021-03-23 17:48:27.621 Status code: 0
. 2021-03-23 17:48:27.621 Transfer done: 'D:\Work\kyc\Test2.txt' => '/MyFolder/NewTest/Test2.txt' [11]
. 2021-03-23 17:48:27.622 Copying finished: Transferred: 11, Elapsed: 0:00:00, CPS: 0/s
. 2021-03-23 17:48:27.622 Listing directory "/MyFolder/NewTest".
> 2021-03-23 17:48:27.622 Type: SSH_FXP_OPENDIR, Size: 23, Number: 3595
. 2021-03-23 17:48:27.622 Sent 27 bytes
. 2021-03-23 17:48:27.622 There are 0 bytes remaining in the send buffer
. 2021-03-23 17:48:27.622 Waiting for another 4 bytes
. 2021-03-23 17:48:27.640 Detected network event
. 2021-03-23 17:48:27.640 Waiting for another 4 bytes
. 2021-03-23 17:48:27.640 Received 14 bytes
. 2021-03-23 17:48:27.640 Read 4 bytes (10 pending)
. 2021-03-23 17:48:27.640 Read 10 bytes (0 pending)
< 2021-03-23 17:48:27.640 Type: SSH_FXP_HANDLE, Size: 10, Number: 3595
> 2021-03-23 17:48:27.640 Type: SSH_FXP_READDIR, Size: 10, Number: 3852
. 2021-03-23 17:48:27.640 Sent 14 bytes
. 2021-03-23 17:48:27.640 There are 0 bytes remaining in the send buffer
. 2021-03-23 17:48:27.640 Waiting for another 4 bytes
. 2021-03-23 17:48:27.652 Detected network event
. 2021-03-23 17:48:27.652 Waiting for another 4 bytes
. 2021-03-23 17:48:27.652 Received 332 bytes
. 2021-03-23 17:48:27.652 Read 4 bytes (328 pending)
. 2021-03-23 17:48:27.652 Read 328 bytes (0 pending)
< 2021-03-23 17:48:27.652 Type: SSH_FXP_NAME, Size: 328, Number: 3852
> 2021-03-23 17:48:27.652 Type: SSH_FXP_READDIR, Size: 10, Number: 4108
. 2021-03-23 17:48:27.652 Sent 14 bytes
. 2021-03-23 17:48:27.652 There are 0 bytes remaining in the send buffer
. 2021-03-23 17:48:27.652 Read file 'panImage.jpg' from listing
. 2021-03-23 17:48:27.652 Read file 'TEST.pdf' from listing
. 2021-03-23 17:48:27.652 Read file 'Test2.txt' from listing
. 2021-03-23 17:48:27.652 Waiting for another 4 bytes
. 2021-03-23 17:48:27.662 Detected network event
. 2021-03-23 17:48:27.662 Waiting for another 4 bytes
. 2021-03-23 17:48:27.662 Received 32 bytes
. 2021-03-23 17:48:27.662 Read 4 bytes (28 pending)
. 2021-03-23 17:48:27.662 Read 28 bytes (0 pending)
< 2021-03-23 17:48:27.662 Type: SSH_FXP_STATUS, Size: 28, Number: 4108
< 2021-03-23 17:48:27.662 Status code: 1
> 2021-03-23 17:48:27.663 Type: SSH_FXP_CLOSE, Size: 10, Number: 4356
. 2021-03-23 17:48:27.663 Sent 14 bytes
. 2021-03-23 17:48:27.663 There are 0 bytes remaining in the send buffer
. 2021-03-23 17:48:27.663 panImage.jpg;-;926778;2021-03-22T13:28:50.000Z;3;"user" [0];"group" [0];-w--w--w-;1
. 2021-03-23 17:48:27.663 TEST.pdf;-;1057344;2021-03-22T13:35:46.000Z;3;"user" [0];"group" [0];-w--w--w-;1
. 2021-03-23 17:48:27.663 Test2.txt;-;11;2021-03-23T09:42:55.000Z;3;"user" [0];"group" [0];-w--w--w-;1
. 2021-03-23 17:48:27.663 ..;D;0;1899-12-30T05:30:00.000Z;0;"" [0];"" [0];---------;0
. 2021-03-23 17:48:28.038 Session upkeep
. 2021-03-23 17:48:28.552 Session upkeep
. 2021-03-23 17:48:29.070 Session upkeep
. 2021-03-23 17:48:29.589 Session upkeep
. 2021-03-23 17:48:29.589 Detected network event
. 2021-03-23 17:48:30.087 Session upkeep
. 2021-03-23 17:48:30.589 Session upkeep
. 2021-03-23 17:48:31.091 Session upkeep
. 2021-03-23 17:48:31.593 Session upkeep
. 2021-03-23 17:48:31.593 Received 28 bytes

java sftp sshj
1个回答
0
投票

dest
SFTPClient.put
参数是文件的路径,而不是目标目录的路径。错误消息对此很清楚。

所以,像这样:

String remoteFilePath = "/MyFolder/NewTest/Test.pdf";
© www.soinside.com 2019 - 2024. All rights reserved.