Solved

Recive filestream to local filesystem.

Posted on 2004-04-11
4
506 Views
Last Modified: 2010-04-05
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
0
Comment
Question by:jontebgood
  • 2
  • 2
4 Comments
 
LVL 17

Expert Comment

by:mokule
ID: 10802746
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;
0
 

Author Comment

by:jontebgood
ID: 10803732
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
0
 
LVL 17

Accepted Solution

by:
mokule earned 500 total points
ID: 10804345
Yes.
There is no information on server side at what position append. It is always appended at the end of currently stored file. It is the responsibility of client to send chunks in proper order.
0
 

Author Comment

by:jontebgood
ID: 10804745
Thanks...

Best regards

J
0

Featured Post

Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

Join & Write a Comment

Objective: - This article will help user in how to convert their numeric value become words. How to use 1. You can copy this code in your Unit as function 2. than you can perform your function by type this code The Code   (CODE) The Im…
Hello everybody This Article will show you how to validate number with TEdit control, What's the TEdit control? TEdit is a standard Windows edit control on a form, it allows to user to write, read and copy/paste single line of text. Usua…
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…
This video explains how to create simple products associated to Magento configurable product and offers fast way of their generation with Store Manager for Magento tool.

757 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

22 Experts available now in Live!

Get 1:1 Help Now