• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • Ron McLeod
  • paul wheaton
  • Jeanne Boyarsky
Sheriffs:
  • Paul Clapham
  • Devaka Cooray
Saloon Keepers:
  • Tim Holloway
  • Roland Mueller
  • Himai Minh
Bartenders:

zehon FTP Files Transfered successfully but folder relative to home

 
Ranch Hand
Posts: 162
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Ranch Hand
Posts: 781
Netbeans IDE Ubuntu Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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?
 
Justin Howard
Ranch Hand
Posts: 162
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks a lot James. That helps me understand why it might be behaving like that.
 
Justin Howard
Ranch Hand
Posts: 162
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 781
Netbeans IDE Ubuntu Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic