Meaningless Drivel is fun!*
The moose likes Java in General and the fly likes zehon FTP Files Transfered successfully but folder relative to home Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "zehon FTP Files Transfered successfully but folder relative to home" Watch "zehon FTP Files Transfered successfully but folder relative to home" New topic
Author

zehon FTP Files Transfered successfully but folder relative to home

Justin Howard
Ranch Hand

Joined: Feb 19, 2009
Posts: 162
Hi All,

I have a strange problem using zehon FTP. I am trying to upload fies to a linux server.
The file is always getting uploaded to the home folder specified in passwd file for the username + file path I specify.

How can I make it move files to the full folder path I specify instead of home folder + filepath.

This is the code. Here if the destination I want to be is "/products/data" but it creates it in
"/products/home/possvr//products/data"



Thanks for your time.
James Sabre
Ranch Hand

Joined: Sep 07, 2004
Posts: 781

You don't say what FTP server you are accessing. For security the better FTP servers limit FTP access to the home directory (and of course it's subdirectory tree) of the user logging on. With these servers, any directory one specifies on the server is assumed relative to the login user's home directory. On the assumption that you are using one of the better FTP servers, I see two possible approaches to solving your problem -

1) create an account that has /products/data as it's home directory and then changing your code to login using the credentials of this new account.
2) put a soft link in your user's home directory pointing to /products/data and make sure the user is in a group having write access to that directory.

P.S. You really wouldn't want an arbitrary account to be able to access arbitrary directories on your system would you?


Retired horse trader.
 Note: double-underline links may be advertisements automatically added by this site and are probably not endorsed by me.
Justin Howard
Ranch Hand

Joined: Feb 19, 2009
Posts: 162
Thanks a lot James. That helps me understand why it might be behaving like that.
Justin Howard
Ranch Hand

Joined: Feb 19, 2009
Posts: 162
Hi James,

In order to eliminate the doubt of permissions. I tried to upload the same file with Apache Commons library for FTP.
Works like a charm. I would have used the same library however they do not support SFTP.

I checked the javadoc for zehon and it does not say anything about appending root to filepath.

Not sure how to troubleshoot further.

Thanks
James Sabre
Ranch Hand

Joined: Sep 07, 2004
Posts: 781

The implication is that that FTP server is dreadfully insecure when referenced in basic FTP mode in that, subject to the normal *nix file access limitations, it allows a client to roam all over the server but in secure mode it limits access. Besides implementing one of the solutions I proposed in my earlier post you should also disable the basic FTP mode since it is compromising the security of your server.

You seem to think that there is some action you can take in your client to overcome the access imitations in SFTP mode. If there is there shouldn't be since this would compromise security.
Ans Kund
Greenhorn

Joined: Mar 14, 2011
Posts: 1
hi Justin,

I guess, you might have resolved this already by now. But it may just help someone else. Zehon offers a utility client called SFTPClient.
So, what you could have done is a a utility class which has a instance variable as say ChangeRemoteDir which gets set to the dir of your choice and then calls the SFTPClient method as is.
So, it can be something like -

where remoteFilePath is the one you have already set before this call.
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: zehon FTP Files Transfered successfully but folder relative to home
 
Similar Threads
files are not delete
Reading log files from various unix servers through Java program on windows
File upload into project structure
FTPClient : is not working
Move file to new folder