I have a problem with SFTP (Windows with WinSSHD ). I am trying to write a file to a folder with Apache Commons VFS . On local SFTP, I have no problems loading, but on second SFTP I always get the error below.
FTP looks like this: 
I need to upload to the "alis" folder. It is strange that he does not have user / group rights and 770. However, with FileZilla, downloading files works fine (the same login is used).
Executing "manager.resolveFile ()" in the "alis" folder (I'm trying to load it into this folder) and typing ".getType ()", I get the "File" information, not the "Folder" as expected.
Does anyone have an idea why VFS recognizes the folder as a file or why the download does not work?
Exception when uploading a file to SFTP:
Exception in thread "main" java.lang.RuntimeException: org.apache.commons.vfs2.FileSystemException: Could not copy "file:///D:/Test/test.txt" to "sftp://user:***@host/.../alis/test.txt". at test.Test.upload(Test.java:77) at test.Test.main(Test.java:22) Caused by: org.apache.commons.vfs2.FileSystemException: Could not copy "file:///D:/Test/test.txt" to "sftp://user:***@host/.../alis/test.txt". at org.apache.commons.vfs2.provider.AbstractFileObject.copyFrom(AbstractFileObject.java:1062) at test.Test.upload(Test.java:73) ... 1 more Caused by: org.apache.commons.vfs2.FileSystemException: Could not create folder "sftp://user:***@host/.../alis" because it already exists and is a file. at org.apache.commons.vfs2.provider.AbstractFileObject.createFolder(AbstractFileObject.java:968) at org.apache.commons.vfs2.provider.AbstractFileObject.getOutputStream(AbstractFileObject.java:1424) at org.apache.commons.vfs2.provider.DefaultFileContent.getOutputStream(DefaultFileContent.java:461) at org.apache.commons.vfs2.provider.DefaultFileContent.getOutputStream(DefaultFileContent.java:441) at org.apache.commons.vfs2.FileUtil.copyContent(FileUtil.java:111) at org.apache.commons.vfs2.provider.AbstractFileObject.copyFrom(AbstractFileObject.java:1053) ... 2 more
Source code: (to run the example you need "jsch-0.1.50.jar")
import java.io.File; import org.apache.commons.vfs2.FileObject; import org.apache.commons.vfs2.FileSystemException; import org.apache.commons.vfs2.FileSystemOptions; import org.apache.commons.vfs2.Selectors; import org.apache.commons.vfs2.impl.StandardFileSystemManager; import org.apache.commons.vfs2.provider.sftp.SftpFileSystemConfigBuilder; public class Test { public static void main(String[] args) { upload("host", "user", "password", "D:/Test/test.txt", "/../alis/test.txt"); } public static FileSystemOptions createDefaultOptions() throws FileSystemException {
source share