Our Products:   CompleteFTP  edtFTPnet/Free  edtFTPnet/PRO  edtFTPj/Free  edtFTPj/PRO
0 votes
5.7k views
in Java FTP by (160 points)
Client: SecureFileTransferClient
Method: UploadStream

We would like to upload a file in following way:
CMD > STOR /path/file.name

Now it's uloaded in such a way
CMD > Change directory to /path
STOR file.name

How we can configure such a behavior? As far as we know changing directories is not necessary and when we upload a lot of files whole uploads takes much longer than they should, becase of many change directory commands.

Another problem is that when we upload two files, example:
/path/fileA.name
/path/fileB.name

It does this:
CMD > Change directory to /path
STOR fileA.name
CMD > Change directory to /path
STOR fileB.name

Why it changes directory two times to the same?

For us the desired behavior would be:
STOR /path/fileA.name
STOR /path/fileB.name

Thank you for your support.

3 Answers

0 votes
by (160 points)
Maybe I will also post some logs:
<REPLY 220-Complete FTP server>
<REPLY 220 CompleteFTP v 5.0.0>
<REPLY 331 Password required for pass>
<REPLY 230 User pass logged in.>
<REPLY 200 Type set to I>
<REPLY 257 "/Home/User" is current directory.>
<REPLY 250 Directory changed to "/Home/User".> !!!COMMENT: Why? It already is in this directory!
<REPLY 257 Created directory "src".>
<REPLY 250 Directory changed to "/Home/User".> !!!COMMENT: This is silly
<REPLY 250 Directory changed to "/Home/User".> !!!COMMENT: This is silly
<REPLY 227 Entering Passive Mode (192,168,1,101,234,26).>
<REPLY 150 Opening BINARY mode data connection for .classpath>
<REPLY 226 Transfer complete, 200,0 KB/s>
<REPLY 250 Directory changed to "/Home/User".>
<REPLY 250 Directory changed to "/Home/User".>
<REPLY 227 Entering Passive Mode (192,168,1,101,234,27).>
<REPLY 150 Opening BINARY mode data connection for .project>
<REPLY 226 Transfer complete, 200,0 KB/s>
<REPLY 250 Directory changed to "/Home/User".> !!!COMMENT: It opens subpath after subpath instead of opening whole path at once.
<REPLY 250 Directory changed to "/Home/User/src".>
<REPLY 257 Created directory "main".>
0 votes
by (162k points)
This is because SecureFileTransferClient has a connection pool, and each operation can be performed on a different connection. So in your example, each STOR operation could be performed on a different connection, and so each connection needs the directory changed.

The reason why STOR /path/fileA.name is not used is because this is not reliable across all servers - it doesn't always work.

Using SSLFTPClient may be more suitable for what you are trying to do if you do not require SFTP support.
0 votes
by (162k points)
In 3.6.1, we've added a method to SecureFileTransferClient called setChangeIntoPathDirectory(boolean), which controls whether or not the client actually changes into the directory. By default it does, but this can now be switched off.

Categories

...