Link to home
Start Free TrialLog in
Avatar of jontebgood
jontebgood

asked on

Recive filestream to local filesystem.

Hi there folks

Im trying to do a FTP server for recive  files from a FTP client via a filestream. Im trying to do the ftp server with the indy component.  FTPServer.

In the demo they just show how to retrive a file. and i know nothing of how to use tfilestream
It would be nice if u show me how to recive a new file and how to appaend if the file is not completly uploaded yet.

plz help me

Regards

J
Avatar of mokule
mokule
Flag of Poland image

Hi

// upload file from client and store (or append) in server

procedure TForm1.IdFTPServer1StoreFile(ASender: TIdFTPServerThread;
  const AFileName: String; AAppend: Boolean; var VStream: TStream);
begin
  ListBox1.Items.Add('Store: ' + ASender.Username + ' - ' + AFileName);
  if AAppend and FileExists(AFileName) then
    begin
    VStream := TFileStream.Create(AFileName,fmOpenReadWrite);
    end
  else
    VStream := TFileStream.Create(AFileName,fmCreate);
end;


// download file from server to client
procedure TForm1.IdFTPServer1RetrieveFile(ASender: TIdFTPServerThread;
  const AFileName: String; var VStream: TStream);
begin
  ListBox1.Items.Add('Retrieve: ' + ASender.Username + ' - ' + AFileName);
  VStream := TFileStream.Create(AFileName,fmOpenRead + fmShareDenyWrite);
end;
Avatar of jontebgood
jontebgood

ASKER

Thanks! in the append part... U just check if the file exsists.... if it does but someone have upload it so it is complete`? then it seems to me that the file will be corrupt right?

Regards
ASKER CERTIFIED SOLUTION
Avatar of mokule
mokule
Flag of Poland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Thanks...

Best regards

J