Solved

Indy Problem

Posted on 2003-11-14
5
459 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
  • 2
5 Comments
 
LVL 24

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

What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
delphi custom sort exception 6 111
Delphi - replicating a form 8 57
Delphi XE10 Round Image 2 50
Working with hours 3 31
The uses clause is one of those things that just tends to grow and grow. Most of the time this is in the main form, as it's from this form that all others are called. If you have a big application (including many forms), the uses clause in the in…
Introduction The parallel port is a very commonly known port, it was widely used to connect a printer to the PC, if you look at the back of your computer, for those who don't have newer computers, there will be a port with 25 pins and a small print…
This video gives you a great overview about bandwidth monitoring with SNMP and WMI with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're looking for how to monitor bandwidth using netflow or packet s…
This video shows how to remove a single email address from the Outlook 2010 Auto Suggestion memory. NOTE: For Outlook 2016 and 2013 perform the exact same steps. Open a new email: Click the New email button in Outlook. Start typing the address: …

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

Need Help in Real-Time?

Connect with top rated Experts

24 Experts available now in Live!

Get 1:1 Help Now