2012-03-16 4 views
2

Windows 및 MacOS X에서 호환되는 firemonkey의 URL을 통해 파일을 다운로드하려면 어떻게해야합니까? 다운로드는 https 이상이어야합니다.Delphi XE2 Firemonkey 파일 다운로드?

+3

Indy는 Windows와 OSX를 지원하므로 'TIdHTTP'구성 요소를 사용해보십시오. 인터넷 사용 방법에 대한 샘플이 가득합니다. – RRUZ

답변

4

XE2와 함께 제공되는 Indy는 Mac OSX를 지원합니다.
참조 :

File-> New (Firemonkey HD app) 
Add Mac OSX as target platform 
Place a TIdHTTP component on the form 
Place a TEdit on the form 

다음의 코드는, 몇 가지 초보적인 결과를 조언의

type 
    TForm16 = class(TForm) 
    IdHTTP1: TIdHTTP; 
    Edit1: TEdit; 
    procedure Edit1Enter(Sender: TObject); 
    public 
    MyFile: TFileStream; 
    end; 

implementation 

{$R *.fmx} 

procedure TForm16.Edit1Enter(Sender: TObject); 
var 
    Success: boolean; 
begin 
    if (MyFile = nil) then try 
    //Correct path handling to be added 
    //filename should be extracted from the url etc etc. 
    MyFile:= TFileStream.Create('Test.dat',fmCreate); 
    Success:= true; 
    except 
    Success:= false; 
    end; 
    if Success then begin 
    IdHTTP1.Get(Edit1.Text, MyFile); 
    //do stuff with the file 
    end; 
end; 

한 단어를 얻을이 http 먼저 https 수와 함께 작동하는지 확인해야합니다 여기 Does Delphi XE2 FireMonkey support Indy for cross-platform apps?

는 워크 플로 설정이 까다로울 수 있습니다.
또한 최신 버전의 Indy가 설치되어 있고 최신 XE2 업데이트가 설치되어 있는지 확인하십시오.