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

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

对远程服务器执行 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,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,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,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,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,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,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,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,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,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,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,Number: 3595
> 2021-03-23 17:48:27.640 Type: SSH_FXP_READDIR,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,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,Number: 4108
< 2021-03-23 17:48:27.662 Status code: 1
> 2021-03-23 17:48:27.663 Type: SSH_FXP_CLOSE,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

解决方法

SFTPClient.putdest 参数是文件的路径,而不是目标目录的路径。错误信息对此相当清楚。

所以,像这样:

String remoteFilePath = "/MyFolder/NewTest/Test.pdf";

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。

相关推荐


使用本地python环境可以成功执行 import pandas as pd import matplotlib.pyplot as plt # 设置字体 plt.rcParams[&#39;font.sans-serif&#39;] = [&#39;SimHei&#39;] # 能正确显示负号 p
错误1:Request method ‘DELETE‘ not supported 错误还原:controller层有一个接口,访问该接口时报错:Request method ‘DELETE‘ not supported 错误原因:没有接收到前端传入的参数,修改为如下 参考 错误2:cannot r
错误1:启动docker镜像时报错:Error response from daemon: driver failed programming external connectivity on endpoint quirky_allen 解决方法:重启docker -&gt; systemctl r
错误1:private field ‘xxx‘ is never assigned 按Altʾnter快捷键,选择第2项 参考:https://blog.csdn.net/shi_hong_fei_hei/article/details/88814070 错误2:启动时报错,不能找到主启动类 #
报错如下,通过源不能下载,最后警告pip需升级版本 Requirement already satisfied: pip in c:\users\ychen\appdata\local\programs\python\python310\lib\site-packages (22.0.4) Coll
错误1:maven打包报错 错误还原:使用maven打包项目时报错如下 [ERROR] Failed to execute goal org.apache.maven.plugins:maven-resources-plugin:3.2.0:resources (default-resources)
错误1:服务调用时报错 服务消费者模块assess通过openFeign调用服务提供者模块hires 如下为服务提供者模块hires的控制层接口 @RestController @RequestMapping(&quot;/hires&quot;) public class FeignControl
错误1:运行项目后报如下错误 解决方案 报错2:Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.8.1:compile (default-compile) on project sb 解决方案:在pom.
参考 错误原因 过滤器或拦截器在生效时,redisTemplate还没有注入 解决方案:在注入容器时就生效 @Component //项目运行时就注入Spring容器 public class RedisBean { @Resource private RedisTemplate&lt;String
使用vite构建项目报错 C:\Users\ychen\work&gt;npm init @vitejs/app @vitejs/create-app is deprecated, use npm init vite instead C:\Users\ychen\AppData\Local\npm-
参考1 参考2 解决方案 # 点击安装源 协议选择 http:// 路径填写 mirrors.aliyun.com/centos/8.3.2011/BaseOS/x86_64/os URL类型 软件库URL 其他路径 # 版本 7 mirrors.aliyun.com/centos/7/os/x86
报错1 [root@slave1 data_mocker]# kafka-console-consumer.sh --bootstrap-server slave1:9092 --topic topic_db [2023-12-19 18:31:12,770] WARN [Consumer clie
错误1 # 重写数据 hive (edu)&gt; insert overwrite table dwd_trade_cart_add_inc &gt; select data.id, &gt; data.user_id, &gt; data.course_id, &gt; date_format(
错误1 hive (edu)&gt; insert into huanhuan values(1,&#39;haoge&#39;); Query ID = root_20240110071417_fe1517ad-3607-41f4-bdcf-d00b98ac443e Total jobs = 1
报错1:执行到如下就不执行了,没有显示Successfully registered new MBean. [root@slave1 bin]# /usr/local/software/flume-1.9.0/bin/flume-ng agent -n a1 -c /usr/local/softwa
虚拟及没有启动任何服务器查看jps会显示jps,如果没有显示任何东西 [root@slave2 ~]# jps 9647 Jps 解决方案 # 进入/tmp查看 [root@slave1 dfs]# cd /tmp [root@slave1 tmp]# ll 总用量 48 drwxr-xr-x. 2
报错1 hive&gt; show databases; OK Failed with exception java.io.IOException:java.lang.RuntimeException: Error in configuring object Time taken: 0.474 se
报错1 [root@localhost ~]# vim -bash: vim: 未找到命令 安装vim yum -y install vim* # 查看是否安装成功 [root@hadoop01 hadoop]# rpm -qa |grep vim vim-X11-7.4.629-8.el7_9.x
修改hadoop配置 vi /usr/local/software/hadoop-2.9.2/etc/hadoop/yarn-site.xml # 添加如下 &lt;configuration&gt; &lt;property&gt; &lt;name&gt;yarn.nodemanager.res