Autor Beitrag
Regan
ontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic starofftopic star
Beiträge: 2157
Erhaltene Danke: 72


Java (Eclipse), Python (Sublimetext 3)
BeitragVerfasst: Mo 05.06.06 20:30 
Hallo,

ich möchte mit einer idhttp Komponente eine Datei herunterladen. Vielleicht geht das auch einfacher als wie ich das hier habe. Den Quelltext habe ich auch nur übernommen:

ausblenden volle Höhe Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
43:
44:
45:
46:
47:
48:
49:
50:
51:
52:
53:
54:
55:
56:
57:
58:
59:
60:
61:
62:
63:
64:
65:
var
  BytesKopiert, BytesInsgesamt : int64;
  lStream: TFileStream;
begin

  Status.Caption := '';
  BytesKopiert := 0;
  Progress.Position := 0;

  Status.Caption := 'Prüfe Header';

  IdHTTP1.Head(Edit1.Text);
  BytesInsgesamt := IdHTTP1.Response.ContentLength;
 
  if BytesInsgesamt = -1 then
  begin
    Status.Caption := 'Normalles herunterladen';
    Status.Caption := 'Erstelle Datei';
    
    lStream:=TFileStream.Create(Edit2.Text, fmCreate or fmShareDenyNone);
    try
      idHTTP1.Get(Edit1.Text, lStream);
    finally
      if Assigned(lStream) then lStream.Free;
    end;
   
    Status.Caption := 'Fertig';
    SpeedStatus.caption := 'Fertig';
    exit;
  end;
  
  Progress.Max := BytesInsgesamt;
  Status.Caption := 'Erstelle Datei';
 
  lStream:=TFileStream.Create(Edit2.Text, fmCreate or fmShareDenyNone);
  lStream.Position := 0;
  try
    repeat
       Application.ProcessMessages;
     
      IdHTTP1.Request.ContentRangeStart := BytesKopiert;
      
      if (BytesInsgesamt-BytesKopiert) > cFileSplitSize then
      begin
        
        IdHTTP1.Request.ContentRangeEnd := BytesKopiert+cFileSplitSize-1;
      end
      
      else IdHTTP1.Request.ContentRangeEnd := BytesInsgesamt;
      Application.ProcessMessages;
     
      IdHTTP1.Get(Edit1.Text, lStream);
      
      Progress.Position := BytesKopiert;
      Status.Caption := GetSizeName(BytesKopiert)+'/'+GetSizeName(BytesInsgesamt);
     
      BytesKopiert := BytesKopiert+cFileSplitSize;
    until (BytesKopiert >= BytesInsgesamt); 
  finally 
    if Assigned(lStream) then lStream.Free; 
  end
  
  Status.Caption := 'Fertig'
  SpeedStatus.caption := 'Fertig'
  Progress.Position := 100;

dabei kommt aber immer der fehler:HTTP/1.1 302 Found

Woran könnte das liegen?
Fighter#1
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 787

Win XP, Ubuntu 8.04
Turbo Delphi 2006, Delphi 2005 Pe, Delphi 5 Pe, Netbeans 6.1, Eclipse, Microsoft VisualC#, Dev C++, PHP, HTML, CSS
BeitragVerfasst: Di 06.06.06 08:14 
Du weißt, du kannst auch sehr einfach mit URLMON und UrlDownloadToFile dateien runterladen IMHO viel geschickter, als mit den Indys rumzuwurschteln.

Es könnte auch dran liegen das die caption des Labels falsch geschrieben ist, Normalles Runterladen :zwinker:

_________________
Wer andere beherrscht ist stark,
wer sich selbst beherrscht ist mächtig. Lao Tse
matze
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 4613
Erhaltene Danke: 24

XP home, prof
Delphi 2009 Prof,
BeitragVerfasst: Di 06.06.06 09:02 
setz mal die Eigenschaft HandleRedirectsauf TRUE.

_________________
In the beginning was the word.
And the word was content-type: text/plain.
Regan Threadstarter
ontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic starofftopic star
Beiträge: 2157
Erhaltene Danke: 72


Java (Eclipse), Python (Sublimetext 3)
BeitragVerfasst: Di 06.06.06 15:05 
user profile iconFighter#1 hat folgendes geschrieben:
Du weißt, du kannst auch sehr einfach mit URLMON und UrlDownloadToFile dateien runterladen IMHO viel geschickter, als mit den Indys rumzuwurschteln.

wo bekomme ich diese Kompo her? muss ich das wie hier machen?:
www.vbarchiv.net/archiv/tipp_476.html
das funktioniert aber nicht so.

user profile iconmatze hat folgendes geschrieben:
setz mal die Eigenschaft HandleRedirects auf TRUE.

funktioniert immer noch nicht
Fighter#1
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 787

Win XP, Ubuntu 8.04
Turbo Delphi 2006, Delphi 2005 Pe, Delphi 5 Pe, Netbeans 6.1, Eclipse, Microsoft VisualC#, Dev C++, PHP, HTML, CSS
BeitragVerfasst: Di 06.06.06 15:15 
URLMON sollte schon dabei sein, einfach bei den uses hinzufügen.
Such im Forum danach, hab das schon so oft erklärt, wurde auch schon so oft von andern erklärt.
Suche in der Entwickler-Ecke URLDOWNLOADTOFILE

_________________
Wer andere beherrscht ist stark,
wer sich selbst beherrscht ist mächtig. Lao Tse
Regan Threadstarter
ontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic starofftopic star
Beiträge: 2157
Erhaltene Danke: 72


Java (Eclipse), Python (Sublimetext 3)
BeitragVerfasst: Di 06.06.06 15:42 
ok ich habs unter www.delphi-forum.de/...ht=urldownloadtofile gefunden.
danke