1 Reply Latest reply: Jan 19, 2010 2:35 AM by gimbal2 RSS

    FTP file upload problem

      I am trying to upload a file to an FTP server. It seems that relatively small files like under 2MB uploads just fine but
      for example 6MB files don't make it to the server. I know this could be done with the storeFile (don't know if that works
      either) but I want to keep track how many bytes has been send so I can update my progressbar.
      JakartaFtpWrapper x = new JakartaFtpWrapper();
      x.connectAndLogin (server, username, password);
      x.binary(); // sets binary transfer
      File file = new File(fileName);         
      InputStream is = new FileInputStream(file);
      OutputStream os = x.storeFileStream(fileName);
      byte[] buffer = new byte[1024];
      int len;
      double progress = 0;
      long fileSize = file.length();          
      while ((len = is.read(buffer)) != -1) {
           progress += len;
           percent = (int) (progress/fileSize*100);
           os.write(buffer, 0, len);
      Why can't I transfer large files :( ?
      Is there a better way to upload the file and monitor the progress? (don't want any pop up dialogs with progress bars)

      Thank You for answers
        • 1. Re: FTP file upload problem
          Who says it is a code problem?

          Did you try uploading a large file to this server using FileZilla or WinSCP or any other FTP client?

          By the way: what do you mean by "doesn't make it". Does the upload stall, or do you get an exception?