2012-03-16 8 views
2

WindowsとMacOS Xの両方で互換性のあるfiremonkeyのURLを使ってファイルをダウンロードするにはどうすればよいですか?ダウンロードはhttpsを超えている必要があります。Delphi XE2 Firemonkeyファイルのダウンロード?

+3

IndyはWindowsとOSXをサポートしているので、「TIdHTTP」コンポーネントを使用してみてください。インターネットはどのように使用されているかに関するサンプルが満載です。 – RRUZ

答えて

4

XE2で提供されているIndyはMac OSXに対応しています。
参照:Does Delphi XE2 FireMonkey support Indy for cross-platform apps?

がここにワークフローです:

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

次のコードは、それが最初httpで動作を確認して、いくつかの初歩的な結果に助言の

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; 

一つの単語を取得する必要があり、https缶セットアップが面倒です。
最新バージョンのIndyがインストールされ、最新のXE2アップデートがインストールされていることも確認してください。

関連する問題