FTP upload via sockets

后端 未结 5 741
一生所求
一生所求 2021-01-26 16:15

how can I upload a file with sockets to a ftp server? I am reading something with \"STOR\" in RFC...It is the same how i transfer a file between two computers?A sample code woul

相关标签:
5条回答
  • 2021-01-26 16:52

    You really do not want to write your own implementation of the FTP protocol - it's not as simple as it might seem at first glance.

    I'm using commons ftp , which gives you a nice API to all ftp operations.

    If you don't need that much control, you could use URLConnection from the standard java library.

    0 讨论(0)
  • 2021-01-26 17:01

    Instead of uploading a file to a ftp I'd suggest that you write your own server and client software and have them communicate with eachother if you want to learn to use sockets in java.

    When you have learned that you can read the RFC for ftp which should tell you how to communicate with the FTP server. You need to learn and understand the ftp protocol in order to construct valid packets with data to send and in order to parse the data you receive from the ftp server.

    its usually requests, responses and data sent back and forth.

    Filedata itself is just sent in its raw form unless the ftp server requires encryption, but requests and responses can be in any form, binary values, decimal values, strings etc all depending on the protocol and the type of request.. You need to know this to setup a valid communication channel.

    I don't know the ftp protocol myself so I'm just demonstrating examples so you'll easier understand what it's all about.

    0 讨论(0)
  • 2021-01-26 17:02

    JavaWorld presents a discussion of some FTP client libraries. To begin with, they even teach you how to use the "built-in" Java URLConnection to do FTP with in a simple way. That should get you started!

    0 讨论(0)
  • 2021-01-26 17:11

    I don´t advice to use raw sockets to upload FTP files, instead use something like SimpleFTP, it's easier to use and it will save you a lot of time. And since you're learning Java, you should do it on the easiest possible way.

    0 讨论(0)
  • 2021-01-26 17:17

    What language are you using? You can use the FTP functions if you have access to the APIs.

    0 讨论(0)
提交回复
热议问题