Results 1 to 6 of 6
  1. #1
    Marco_88 is offline Member
    Join Date
    Jan 2010
    Posts
    4
    Rep Power
    0

    Default FTP send file to server

    Hi all.
    I have a client that must send a file to a server using FTP. I create the sockets, log in with USER and PASS, I connect the sockets of data with PASv and all work. Next I try to send a file with STOR but at the server the file arrives but smaller than the original at client side. And the server does not send me any response .

    For example, if I try to send an image to the server, the image in the client is 73471Bytes but server side is only 73203Bytes, and i cannot open it.

    Can someone help me?

    EDIT-----------------
    Now I receive the response:

    226-File successfully transferred
    226 17.424 seconds (measured here), 16.83 Kbytes per second

    but the file is too small.
    The original size is: 294 KB (301.4 43 byte)
    The destination size on the server is: 293 KB (300.316 byte)

    Why this problem?
    Last edited by Marco_88; 01-08-2010 at 09:33 PM.

  2. #2
    travishein's Avatar
    travishein is offline Senior Member
    Join Date
    Sep 2009
    Location
    Canada
    Posts
    684
    Rep Power
    6

    Default

    is it usiing ascii translation mode (not binary mode as it should)?

  3. #3
    Marco_88 is offline Member
    Join Date
    Jan 2010
    Posts
    4
    Rep Power
    0

    Default

    I have used
    new ObjectOutputStream( socket.getOutputStream() );
    How can I change the translation mode?

    I use:
    var fileDaInviare:File = new File("C:\\onepiece.jpg");
    var sorgenteDaInviare:FileInputStream = new FileInputStream(fileDaInviare);
    //var bis:ObjectInputStream = new ObjectInputStream(sorgenteDaInviare);

    //var bufferF:nativearray of Byte;
    println("Dimensione == {sorgenteDaInviare.available()}");

    var len:Integer =0;
    len = sorgenteDaInviare.read();
    while (len != -1) {
    try {
    writeData.writeByte(len);
    writeData.flush();
    len = sorgenteDaInviare.read();
    } catch(ex : IOException) {
    ex.printStackTrace();
    }


    //println("Scritti {len} Bytes");
    }
    Last edited by Marco_88; 01-09-2010 at 11:37 AM.

  4. #4
    FON
    FON is offline Senior Member
    Join Date
    Dec 2009
    Location
    Belgrade, Serbia
    Posts
    368
    Rep Power
    5

    Default

    If travishein's point is right
    i suggest that you try using:
    "Commons Net 2.0 API"

    Inside you will find:


    Java Code:
    org.apache.commons.net.SocketClient
          org.apache.commons.net.ftp.FTP
              org.apache.commons.net.ftp.FTPClient
    You make client easily by just extending FTPClient class,
    and you use

    Java Code:
    setFileType(FTP.BINARY_FILE_TYPE)
    You can go trough source code of parent classes
    like SocketClient to see what happens on Socket level.

    good luck

  5. #5
    Marco_88 is offline Member
    Join Date
    Jan 2010
    Posts
    4
    Rep Power
    0

    Default

    Thanks!
    Now I try to use it.

  6. #6
    Marco_88 is offline Member
    Join Date
    Jan 2010
    Posts
    4
    Rep Power
    0

    Default

    Ok it work!
    Thanks for all!
    Last edited by Marco_88; 01-09-2010 at 03:50 PM.

Similar Threads

  1. send file via client - server model
    By spasavvas in forum Networking
    Replies: 15
    Last Post: 08-13-2010, 11:45 AM
  2. how to send mp3 file from server to client
    By Jigga008 in forum Networking
    Replies: 0
    Last Post: 12-01-2009, 12:02 PM
  3. Replies: 3
    Last Post: 07-29-2009, 04:52 AM
  4. how can server send messages every 5 min?
    By dim_ath in forum Networking
    Replies: 7
    Last Post: 01-10-2008, 03:59 PM
  5. send/read int in a client/server app
    By dim_ath in forum New To Java
    Replies: 2
    Last Post: 01-03-2008, 01:03 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •