Einzelnen Beitrag anzeigen

Klaus01

Registriert seit: 30. Nov 2005
Ort: München
5.771 Beiträge
 
Delphi 10.4 Sydney
 
#6

Re: Indy FTP Client Upload fortführen

  Alt 8. Mai 2009, 10:22
Zitat von experts-exchange:
Hi there Rogerio,

I don't have much time to test the code in a machine with Delphi, but with Indy10, resume support is built-in.

Check out the Put command, where the 3rd parameter (AApend) is a Boolean value. Set that to True, and it will auto resume *if* the FTP server supports resuming.

So, all you need to do is to do something like:
Delphi-Quellcode:
var
  F: TFileStream;
  DoResume: Boolean;
  iSize: Integer;
begin
  DoResume := False;
  F := TFileStream.Create('Somefile.dat', fmOpenRead or fmShareDenyNone);
  try
    with idFTP1 do
    begin
      // code for connecting to FTP Server goes here...

      iSize := Size('Somefile.dat');
      if (iSize > -1) and (F.Size > iSize) then
      // if the file already exists, and the destination file is smaller, check if we want to resume
        if CanResume
          DoResume := MessageDlg('FTP Server supports Resume. Do you want to resume the previous transfer?',
            mtConfirmation, [mbYes, mbNo], 0) = mrYes;
      Put(F, 'Somefile.dat', DoResume);
    end;
  finally
    F.Free;
  end;
end;
rogerbrito:Hi DragonSlayer.

I have tried that. Using a filename as the first parameter the entire file would be appended no to destination file, and not only the missing part. I also tried using a Stream (as in your example). That worked, but the destination file would always be incomplete (a few kbytes short).

So I've changed to ICS FTPCli component (http://www.overbyte.be) . It's free and I've found a resume upload example that works! I have already implemented it on my application and it is working great!

Thank you for help anyway.

Rogerio


DragonSlayer:Hi Rogerio, I forgot one piece of code... I think you actually need to perform a Seek to the right position in your stream before calling Put. Glad that


Klaus
  Mit Zitat antworten Zitat