Recent

Author Topic: FTP Upload not working correctly  (Read 176 times)

uptownwings

  • Newbie
  • Posts: 1
FTP Upload not working correctly
« on: March 09, 2020, 06:10:17 pm »
Hi guys.

I am running into the following issue.
Whenever I need to upload small files, everything is okay. Like 6k, 9k files, no problems there.
But when the files are bigger, a small portion is uploaded and then the upload just seems to die and timeout. I do not know what is going on. I tried several FTP locations that I know have different server software running, I tried different libraries to do this (Synapse and Codebot). Both with the exact -same- result.
It is just weird  and I can't figure out what is going on. What am I missing here?

I created a quick and dirty example program as follows:
The codebot library is here: https://github.com/sysrpl/Cross.Codebot

Code: Pascal  [Select][+][-]
  1. unit Main;
  2.  
  3. {$mode objfpc}{$H+}
  4.  
  5. interface
  6.  
  7. uses
  8.   Classes,
  9.   SysUtils,
  10.   Forms,
  11.   Controls,
  12.   Graphics,
  13.   Dialogs,
  14.   ExtCtrls,
  15.   StdCtrls,
  16.   FileUtil,
  17.   codebot.Networking.Ftp,
  18.   codebot.System;
  19.  
  20. type
  21.  
  22.   { TForm1 }
  23.  
  24.   TForm1 = class(TForm)
  25.     Button1: TButton;
  26.     Memo1: TMemo;
  27.     Panel1: TPanel;
  28.     procedure Button1Click(Sender: TObject);
  29.     procedure FormCreate(Sender: TObject);
  30.   private
  31.     FTPClient: TFtpClient;
  32.     procedure Progress(Sender: TObject; const Size, Transmitted: LargeWord);
  33.   public
  34.  
  35.   end;
  36.  
  37. var
  38.   Form1: TForm1;
  39.  
  40. implementation
  41.  
  42. {$R *.lfm}
  43.  
  44. { TForm1 }
  45.  
  46. procedure TForm1.Button1Click(Sender: TObject);
  47. var
  48.   FileList: TStringList;
  49.   i: Integer;
  50. begin
  51.   FileList := TStringList.Create;
  52.   FindAllFiles(FileList,
  53.     '/location/on/your/disk',
  54.     '*', False);
  55.   Memo1.Lines.Clear;
  56.   Memo1.Lines.Add(FileList.Text);
  57.  
  58.   FTPClient.Connect;
  59.   FTPClient.MakeDir('StorageFolder');
  60.   FTPClient.ChangeDir('StorageFolder');
  61.  
  62.   for i := 0 to FileList.Count -1 do begin
  63.     Memo1.Lines.Add('Uploading file ' + ExtractFileName(FileList[i]));
  64.     FTPClient.FilePut(FileList[i], ExtractFileName(FileList[i]));
  65.   end;
  66.  
  67.   FTPClient.Disconnect;
  68. end;
  69.  
  70. procedure TForm1.FormCreate(Sender: TObject);
  71. begin
  72.   FTPClient := TFTPClient.Create;
  73.   FTPClient.Host := 'hostname.domain.tld';
  74.   FTPClient.UserName := 'username';
  75.   FTPClient.Password := 'password';
  76.   FTPClient.OnProgress:=@Progress;
  77. end;
  78.  
  79. procedure TForm1.Progress(Sender: TObject; const Size, Transmitted: LargeWord);
  80. begin
  81.   Memo1.Lines.Add('Progress: ' + IntToStr(Transmitted) + '/' + IntToStr(Size));
  82. end;
  83.  
  84. end.
  85.                  
  86.  

 

TinyPortal © 2005-2018