Non mi è mai servito, ma in Synapse, nell'oggetto THTTPSend c'è questo:
{:if this value is not 0, then data download pending. In this case you have
here total sice of downloaded data. It is good for draw download
progressbar from OnStatus event.}
property DownloadSize: integer read FDownloadSize;
{:if this value is not 0, then data upload pending. In this case you have
here total sice of uploaded data. It is good for draw upload progressbar
from OnStatus event.}
property UploadSize: integer read FUploadSize;
{:Socket object used for TCP/IP operation. Good for seting OnStatus hook, etc.}
property Sock: TTCPBlockSocket read FSock;
Credo che facciano al caso tuo.
Ciao, Mario
Avevo fatto tutto con Indy 10 (li uso in Delphi e quindi mi era stato facile), ma ora probabilmente causa una rel piu' aggiornata ... 10.5.x , non funziona piu' neppure agganciando un Server Linux Ftp; (la versione Delphi funziona ancora correttamente);
ho fatto un test su Lazarus liscio con Indy 10.2.0.3 e la connessione avviene, pero' nessuno garantisce che nell rel. successive possa continuare a funzionare , quindi ho scelto di passare a Synapse.
Sono quasi riuscito a fare quello che serve, eccetto questo dannato OnStatus ...;
Portate pazienza se rompo...
la libreria FtpSend sarebbe piu' idonea sia per leggere una Directory dsl Server Ftp
che per trasferire file tra 2 server
function FtpInterServerTransfer( const FromIP, FromPort, FromFile, FromUser, FromPass: string; const ToIP, ToPort, ToFile, ToUser, ToPass: string): Boolean;
//A very useful function, and example of use can be found in the TFtpSend object. Initiate transfer of file between two FTP servers.
mi resta il problema di come indirizzare l'Evento OnStatus che mi restituisce sempre errore (forse non corrisponde il prototipo di chiamata)
posto le modifiche fatte anche seguendo un'esempio Synapse
http://www.ararat.cz/synapse/doku.php/public:howto:onstatus
//evento per esecuzioine Status della classe CallBack
FTPS.DSock.OnStatus := CallBack.Status;
unit1.pas(226,41) Error: Wrong number of parameters specified for call to "Status"
uses
..., FtpSend, typinfo, blcksock;
dichiaro la classe di appoggio
type
THookSocketStatus = procedure(Sender: TObject; Reason: THookSocketReason; const Value: string) of object;
{ Callback }
Callback = class
class procedure Status (Sender: TObject; Reason: THookSocketReason; const Value: String);
end;
la procedure Status
{ Callback }
class procedure Callback.Status(Sender: TObject; Reason: THookSocketReason;
const Value: String);
var v: String;
begin
v := getEnumName (typeinfo(THookSocketReason), integer(Reason)) + ' ' + Value;
Form1.Memo1.Lines.Add(v);
if (reason=hr_writecount) then
inc(SizeOUT,StrToInt64Def(Value,0));
Form1.Label1.Caption:=inttostr(SizeOUT);
application.ProcessMessages;
end;
creo l'istanza a FtpSend
procedure TForm1.FormCreate(Sender: TObject);
begin
FTPS:= TFTPSend.Create;
end;
ed infine l'esecuzione del trasferimento file e assegnazione Evento
procedure TForm1.Button3Click(Sender: TObject);
var
bEsito: boolean;
Source, TargetFile: string;
Reason: THookSocketReason;
begin
SizeIN:=0;
SizeOUT:=0;
FTPS.TargetHost:= 'ftp.webalice.it';
FTPS.TargetPort := '21';
FTPS.UserName := 'user';
FTPS.Password := 'pwd';
FTPS.DSock.SendMaxChunk := 8192;
if not FTPS.Login then Form1.Caption:= 'Not Connected';
//evento per esecuzioine Status della classe CallBack
FTPS.DSock.OnStatus := CallBack.Status;
Source := '/WA/Immagini/readme_fr.htm';
TargetFile := 'D:\Temp\Test\Messaggi.jpg';
Result := FtpGetFile('ftp.webalice.it', '21', Source, TargetFile, 'user', 'pwd');
end;
sempre da quell'esempio trovo
attaching this callback to a socket:
Sock := T[UDP/TCP/..]BlockSocket.Create;
Sock.OnStatus := callback.Status;
ma non capissco Sock := T[UDP/TCP/..]BlockSocket.Create;
cosa assegnano con T[UDP/TCP/..]