hamed
hamed

Reputation: 8043

How to set working directory on FTPusing FTPClient

I'm using java FTPClient for FTPconnection. This library has storeFile method for saving a file on FTP. I use it like this:

FTPClient ftpClient = new FTPClient();
//code for connection and login
...
ftpClient.storeFile("test.jpg", stream); //stream is an InputStream

Now, I need to set working directory on FTP. For example I want to save my .jpg in the specific folder. Is ftpClient.storeFile("1/test.jpg", stream); correct? Or is there another solution?

Upvotes: 1

Views: 2571

Answers (1)

Predrag Maric
Predrag Maric

Reputation: 24433

I think you should call FTPClient#changeWorkingDirectory() (the docs) prior to storeFile().

Upvotes: 4

Related Questions