• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Sending and handling files in a network

 
Mousa A. Rafi
Greenhorn
Posts: 28
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It might be helpful to read my topic: Keeping an image in database in the JDBC section to understand the main problem.

Well, what I want to do is, send a file (most likely jpg or gif) to another machine on the network and save it in a particular directory of that machine, with the file renamed to something else. For example, I have an image named mypic.jpg. My application will send this file to another machine and it will be saved there as /DBUser/images/user0001.jpg. So, what would be the neat and clean way to do this?

If I were to do this app using web technology, I would send the file using HTTP 'post' method and let the webserver and PHP do the rest on the remote / server machine. I have some experience of making simple client server applications with Java which simply talk to each other. But never worked with protocols. Will FTP be of any help?
 
Stan James
(instanceof Sidekick)
Ranch Hand
Posts: 8791
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
FTP would be well suited because its whole purpose in life is transferring files. I'd probably try for that unless there is some reason an FTP server is not allowed on your network.

HTTP protocols would be some work to build multi-part requests. The Apache HTTP Client package would probably make that simpler. I haven't tried it first hand. It would also be some work to accept the uploaded file to the web server, again because of multi-part request structures. You can find open source or free solutions.

Raw sockets might be easier than HTTP. You have to hand build more of the parts, but you can make up your own very simple protocol.

Any of that sound useful?
 
Mousa A. Rafi
Greenhorn
Posts: 28
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Stan James,
Thanks for your suggestions. They indeed sound useful to me. Well, as you mentioned, FTP is the most suitable solution and as long as it full-fills the constraints I mentioned earlier I'd really want to go for it. But, as you can guess, I wouldn't have started this topic if I knew how to do it in the first place.

What I would really wish for is a short program / example that works with FTP to get myself running and then go for the doc for details and advanced features.

Thanks once again for the help. By the way, I liked that quotation you used for signature.
 
David Harkness
Ranch Hand
Posts: 1646
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You can run a standard ftp daemon on the server. For a client, Jakarta's Commons Net has a simple FTPClient I believe.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic