?
Solved

Indy Problem

Posted on 2003-11-14
5
Medium Priority
?
471 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

Want to be a Web Developer? Get Certified Today!

Enroll in the Certified Web Development Professional course package to learn HTML, Javascript, and PHP. Build a solid foundation to work toward your dream job!

Question has a verified solution.

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

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…
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…
Sometimes it takes a new vantage point, apart from our everyday security practices, to truly see our Active Directory (AD) vulnerabilities. We get used to implementing the same techniques and checking the same areas for a breach. This pattern can re…
In this video, Percona Director of Solution Engineering Jon Tobin discusses the function and features of Percona Server for MongoDB. How Percona can help Percona can help you determine if Percona Server for MongoDB is the right solution for …
Suggested Courses

762 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