Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Indy Problem

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

Technology Partners: 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

In this tutorial I will show you how to use the Windows Speech API in Delphi. I will only cover basic functions such as text to speech and controlling the speed of the speech. SAPI Installation First you need to install the SAPI type library, th…
Have you ever had your Delphi form/application just hanging while waiting for data to load? This is the article to read if you want to learn some things about adding threads for data loading in the background. First, I'll setup a general applica…
Have you created a query with information for a calendar? ... and then, abra-cadabra, the calendar is done?! I am going to show you how to make that happen. Visualize your data!  ... really see it To use the code to create a calendar from a q…
In response to a need for security and privacy, and to continue fostering an environment members can turn to for support, solutions, and education, Experts Exchange has created anonymous question capabilities. This new feature is available to our Pr…
Suggested Courses

610 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