0

I am just wondering... Is there a way to use sftp protocol with httpcomponent apache lib to upload files with multiparting?

I couldn't find any tutorials so it would be greate you to share some code snippets in that direction...

Any useful comments are appreciated

skaffman
  • 398,947
  • 96
  • 818
  • 769
user592704
  • 3,674
  • 11
  • 70
  • 107

1 Answers1

1

Short answer - no, you cannot use HttpComponent to upload files using SFTP. HTTP and SFTP are poles apart. SFTP is even a true protocol on it's own unlike FTP, it is merely a subsystem in a SSH2 server.

If you need to transfer files via SFTP, use a SSH library that supports the SFTP subsystem. If you want to use an Apache library, use Apache VFS as indicated in one of the answers.

Community
  • 1
  • 1
Vineet Reynolds
  • 76,006
  • 17
  • 150
  • 174
  • Thank you for your answer. Emm... But is it possible to use VSF with Applet then? Does it require Sockets or something? – user592704 Jun 24 '11 at 20:34
  • On using VSF with applets, I cannot answer that question definitively, for I haven't done anything similar before; you will therefore have to attempt it. On the second, all file transfers from an applet will end up opening connections, and you might need to sign your applet if the socket is opened to a different host, or if you are doing something that for which the default security permissions are not sufficient. But yes, SSH based file transfers from applets are possible in general; see [JFileUpload](www.jfileupload.com/products/sftp/index.html), which was mentioned in that answer. – Vineet Reynolds Jun 24 '11 at 20:38
  • Oh, but the applet signing is to show the applet is interacting with its native host at least it is made for... so it is the socket based thing right? I know that an applet can really work as a desktop app but it is pretty bad :( Is there some other way to upload files via sftp with no sockets? – user592704 Jun 25 '11 at 01:04
  • All TCP/IP communication will involve sockets. Signing applets will ensure that you can open sockets to servers other than the one which hosts the applet. – Vineet Reynolds Jun 25 '11 at 01:15