Solved

Indy Problem

Posted on 2003-11-14
5
470 Views
Last Modified: 2010-04-05
function FileDownload(AConnection: TConnectionInfo;
    ASourceFile: String; var AMemoryStream: TMemoryStream): Integer; overload;
begin
  Result := 0;
  with TidFTP.Create(nil) do
    try
      Host := AConnection.Host;
      Username := AConnection.Username;
      Password := AConnection.Password;
      //Added By Donskie
      TransferType := ftBinary;
      AsciiFilter := False;
      try
        Connect(False);
        Login;
        Get(ASourceFile, AMemoryStream, False);
        AMemoryStream.Position := 0;
      except
        on E: Exception do Result := -1;
      end;
    finally
      Free;
    end;
end;

procedure TfDictation.Button1Click(Sender: TObject);
var
  ftpConnection : TConnectionInfo;
  sPath : String;
  memStream : TMemoryStream;
begin
  with ftpConnection do
  begin
    Host := '202.162.2.58';
    Username := 'user'
    Password := 'temp';
  end;

  memStream := TMemoryStream.Create;

    if FileDownload(ftpConnection, 'Temp/1.mp3' , MemStream) > -1 then
    ShowMessage('Successfull')
  else
    ShowMessage('Error');
   
    MemStream.SaveToFile('e:\temp.mp3');

end;

the 1.mp3 is 500KB file and i can hear anything in it when i tried to download it using anyFTP client. when i tried indy to get it from the server i can't anymore hear anything. the size is the same with the original but has no voice in it.

is there any problem with the indy included in Delphi 7?
0
Comment
Question by:dopors
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
5 Comments
 
LVL 25

Expert Comment

by:Tomas Helgi Johannsson
ID: 9746136
The IndyFTP server uses TStream in the Store and Retrieve Events. Using TMemoryStream with files can have major problems
when sending data between client / server (or that's my experience at least). I recommend that you use TFileStream instead.

Regards,
  Tomas Helgi
0
 

Author Comment

by:dopors
ID: 9752157
function FileDownload(AConnection: TConnectionInfo;
    ASourceFile: String; var AFileStream: TFileStream): Integer; overload;
begin
  Result := 0;
  with TidFTP.Create(nil) do
    try
      Host := AConnection.Host;
      Username := AConnection.Username;
      Password := AConnection.Password;
      //Added By Donskie
      TransferType := ftBinary;
      AsciiFilter := False;
      try
        Connect(False);
        Login;
        Get(ASourceFile, AFileStream, False);
        AFileStream.Position := 0;
      except
        on E: Exception do Result := -1;
      end;
    finally
      Free;
    end;
end;

procedure TfDictation.Button1Click(Sender: TObject);
var
  ftpConnection : TConnectionInfo;
  sPath : String;
  fileStream : TFileStream;
begin
 with ftpConnection do
  begin
    Host := '202.162.2.58';
    Username := 'user'
    Password := 'temp';
  end;

  fileStream := TFileStream.Create('e:\temp.mp3',fmCreate);

  //'song.mp3'
  if FileDownload(ftpConnection, 'Temp/1.mp3' , fileStream) > -1 then
    ShowMessage('Successfull')
  else
    ShowMessage('Error');
end;

<B>I have tried you suggestion and it is still the same i have attached my code here, maybe i forgot something.</B>
0
 

Author Comment

by:dopors
ID: 9752831
I have already solved this one. can i get back my points on this one.
0
 

Accepted Solution

by:
modulo earned 0 total points
ID: 12791640
PAQed with points refunded (50)

modulo
Community Support Moderator
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Creating an auto free TStringList The TStringList is a basic and frequently used object in Delphi. On many occasions, you may want to create a temporary list, process some items in the list and be done with the list. In such cases, you have to…
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…
Michael from AdRem Software outlines event notifications and Automatic Corrective Actions in network monitoring. Automatic Corrective Actions are scripts, which can automatically run upon discovery of a certain undesirable condition in your network.…
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…

688 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