Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Recive filestream to local filesystem.

Posted on 2004-04-11
4
Medium Priority
?
519 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 2000 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

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

A lot of questions regard threads in Delphi.   One of the more specific questions is how to show progress of the thread.   Updating a progressbar from inside a thread is a mistake. A solution to this would be to send a synchronized message to the…
This article explains how to create forms/units independent of other forms/units object names in a delphi project. Have you ever created a form for user input in a Delphi project and then had the need to have that same form in a other Delphi proj…
Are you ready to place your question in front of subject-matter experts for more timely responses? With the release of Priority Question, Premium Members, Team Accounts and Qualified Experts can now identify the emergent level of their issue, signal…
Screencast - Getting to Know the Pipeline
Suggested Courses

886 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