2
votes

I read in the FTPClient API the following statement:

boolean storeUniqueFile(InputStream local)
Stores a file on the server using a unique name assigned by the server and taking input from the given InputStream.

Source: http://commons.apache.org/proper/commons-net/apidocs/org/apache/commons/net/ftp/FTPClient.html#storeUniqueFile(java.io.InputStream)

How do I know the unique name or path the server assigned for the file? Has anybody used this API before?

1
I don't think you are supposed to, as the client. You are just sending the file to the server and it will handle the naming. You probably have functionality to cd to a specific folder, but when you go to save the file, the server-side is probably just taking over and handles duplicate names for example. - mikemil

1 Answers

1
votes

Finally I didn't find any way to get to know the assigned file name, because even it is not in the FTP server's response. My FTP server (vsftpd 3.0.2 under Ubuntu) for storeUniqueFile command simply answers

226 Transfer complete.

and I don't have any more information. The file is created usually with .1, .2, etc. extension. If I was sure that nobody uses the ftp server concurrently, I could run a listFiles() before and after and simply make a diff. That is all :-(