Autor Beitrag
Delphi2009lover
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 176



BeitragVerfasst: Fr 20.11.09 11:28 
Hi,

ich bins schon wieder^^

ich habe zwei fragen

1. Wie kann ich eine Datei aus dem Internet laden und an einen bestimmten Pfad speichern?

2. Hier hab ich garkeine Ahnung... ich möchte gerne den Fortschritt der Datei die gerade läd anzeigen... wie bekomme ich das denn jetzt hin?


Ich sag jetzt schon mal vielen Dank und sry dass ich heute so viele Fragen hab^^
FinnO
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 1331
Erhaltene Danke: 123

Mac OSX, Arch
TypeScript (Webstorm), Kotlin, Clojure (IDEA), Golang (VSCode)
BeitragVerfasst: Fr 20.11.09 11:30 
helfen kann da indy mit idFTP. Die Suche hilft.
Delphi2009lover Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 176



BeitragVerfasst: Fr 20.11.09 11:43 
Ich will es ja auch nicht mit FTP machen sondern mit HTTP (VideoDownload von Youtube) das währe dann z.B. so ein Link : www.youtube.com/get_...CjzNYROlsNrXbdKT8%3D
jaenicke
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 19326
Erhaltene Danke: 1749

W11 x64 (Chrome, Edge)
Delphi 12 Pro, C# (VS 2022), JS/HTML, Java (NB), PHP, Lazarus
BeitragVerfasst: Fr 20.11.09 11:50 
Er meinte vermutlich auch TIdHttp.
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
uses
  IdHttp;

var
  HttpLoader: TIdHttp;
  PageContents: String;
begin
  HttpLoader := TIdHttp.Create;
  try
    HttpLoader.OnWork := ...
    ...
    PageContents := HttpLoader.Get('http://www.example.com');
  finally
    HttpLoader.Free;
  end;
end;
Da musst du die Ereignisse OnWork, OnBeginWork und OnEndWork zuweisen und implementieren, dann klappt das. Wie das geht siehst du zum Beispiel auch in meinen SJ Updater Utils (SJUpdaterUtils.pas).
Andreas L.
ontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic starofftopic star
Beiträge: 1703
Erhaltene Danke: 25

Windows Vista / Windows 10
Delphi 2009 Pro (JVCL, DragDrop, rmKlever, ICS, EmbeddedWB, DEC, Indy)
BeitragVerfasst: Fr 20.11.09 12:07 
Wobei es bei einem Video wohl sinnvoller ist die Datei in einen MemoryStream oder einen FileStream anstatt eines Strings zu laden.

ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
var
  http: TIdHTTP;
  fs: TFileStream;
begin
  http := TIdHTTP.Create(nil);
  try
    fs := TFileStream.Create('Dateiname', fmCreate);
    try
      http.Get('URL', fs);
    finally
      fs.Free;
    end;
  finally
    http.Free;
  end;
end;
jaenicke
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 19326
Erhaltene Danke: 1749

W11 x64 (Chrome, Edge)
Delphi 12 Pro, C# (VS 2022), JS/HTML, Java (NB), PHP, Lazarus
BeitragVerfasst: Fr 20.11.09 12:10 
Das war auch nur das Standardbeispiel aus meinen Entwürfen, das Anpassen kann er ja auch selbst machen. :mrgreen:
Delphi2009lover Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 176



BeitragVerfasst: Fr 20.11.09 13:21 
Danke, das hat schonmal sehr geholfen, nur wo kann ich jetzt den "Status" auslesen bzw wie?

PS: Des war schon ganz net das er gesagt hat, das das mit einem FIleStream gemacht werden muss^^ ich hätte das bestimmt mit nem String gemacht und hät mich dann gewundert warum nix geht^^
jaenicke
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 19326
Erhaltene Danke: 1749

W11 x64 (Chrome, Edge)
Delphi 12 Pro, C# (VS 2022), JS/HTML, Java (NB), PHP, Lazarus
BeitragVerfasst: Fr 20.11.09 13:23 
user profile iconDelphi2009lover hat folgendes geschrieben Zum zitierten Posting springen:
nur wo kann ich jetzt den "Status" auslesen bzw wie?
user profile iconjaenicke hat folgendes geschrieben Zum zitierten Posting springen:
Da musst du die Ereignisse OnWork, OnBeginWork und OnEndWork zuweisen und implementieren, dann klappt das. Wie das geht siehst du zum Beispiel auch in meinen SJ Updater Utils (SJUpdaterUtils.pas).
Delphi2009lover Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 176



BeitragVerfasst: Di 24.11.09 12:37 
Ich hab grad doch noch ein Problem... wie kann ich die in dem Filestream enthaltene Datei dann speichern?
jaenicke
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 19326
Erhaltene Danke: 1749

W11 x64 (Chrome, Edge)
Delphi 12 Pro, C# (VS 2022), JS/HTML, Java (NB), PHP, Lazarus
BeitragVerfasst: Di 24.11.09 12:45 
Wohin möchtest du die Datei auf der Festplatte denn danach noch speichern? In eine zweite Datei? Dafür kannst du einfach einen weiteren TFileStream nehmen und den Inhalt des ersten mit CopyFrom hineinkopieren.
Delphi2009lover Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 176



BeitragVerfasst: Di 24.11.09 12:51 
Speichert der Filestream nach angabe des Dateinamens automatisch die Datei auf die Festplatte???
thepaine91
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 763
Erhaltene Danke: 27

Win XP, Windows 7, (Linux)
D6, D2010, C#, PHP, Java(Android), HTML/Js
BeitragVerfasst: Di 24.11.09 12:57 
F1 falls das aus i-einem Grund nicht funktioniert im df die Suche benutzen oder google. ;)
Delphi2009lover Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 176



BeitragVerfasst: Di 24.11.09 13:01 
Ja wird der automatisch gespeichert?
Andreas L.
ontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic starofftopic star
Beiträge: 1703
Erhaltene Danke: 25

Windows Vista / Windows 10
Delphi 2009 Pro (JVCL, DragDrop, rmKlever, ICS, EmbeddedWB, DEC, Indy)
BeitragVerfasst: Di 24.11.09 13:03 
user profile iconDelphi2009lover hat folgendes geschrieben Zum zitierten Posting springen:
Ja wird der automatisch gespeichert?


Ja
Delphi2009lover Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 176



BeitragVerfasst: Di 24.11.09 13:07 
Sry wenn ich so genau frag aber^^ ich ärger mich immer so wenn dann nichts geht^^

Also muss ich bei dem Beispiel das Wort Dateiname durch den Pfad z.B. C:/Users/Dokumente/VIDEO.avi ersetzen?
Andreas L.
ontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic starofftopic star
Beiträge: 1703
Erhaltene Danke: 25

Windows Vista / Windows 10
Delphi 2009 Pro (JVCL, DragDrop, rmKlever, ICS, EmbeddedWB, DEC, Indy)
BeitragVerfasst: Di 24.11.09 13:15 
user profile iconDelphi2009lover hat folgendes geschrieben Zum zitierten Posting springen:


Also muss ich bei dem Beispiel das Wort Dateiname durch den Pfad z.B. C:/Users/Dokumente/VIDEO.avi ersetzen?


Ja, aber warum probierst du es nicht einfach mal aus? :roll:
Delphi2009lover Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 176



BeitragVerfasst: Di 24.11.09 13:16 
KA wenn ich sicher weiß dass das so geht, weiß ich ja, dass es daran nicht liegen kann wenn etwas nicht geht
hansa
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 3079
Erhaltene Danke: 9



BeitragVerfasst: Di 24.11.09 13:32 
Und wenn es geht, dann wird es nicht gemacht ? :rofl:

_________________
Gruß
Hansa
Bergmann89
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 1742
Erhaltene Danke: 72

Win7 x64, Ubuntu 11.10
Delphi 7 Personal, Lazarus/FPC 2.2.4, C, C++, C# (Visual Studio 2010), PHP, Java (Netbeans, Eclipse)
BeitragVerfasst: Di 24.11.09 13:54 
Hey,

wie genau funzt das mit der Porgressbar, weil wenn ich das so mach wie unten, dann läuft die mehr als einmal durch?!

ausblenden 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:
procedure TForm1.Button1Click(Sender: TObject);
begin
  Memo1.Text := HTTP.Get(Edit1.Text);
end;

procedure TForm1.HTTPWorkBegin(Sender: TObject; AWorkMode: TWorkMode;
  const AWorkCountMax: Integer);
begin
  ProgressBar.Min := 0;
  ProgressBar.Max := AWorkCountMax;
  ProgressBar.Step := 1;
  ProgressBar.Position := 0;
end;

procedure TForm1.HTTPWorkEnd(Sender: TObject; AWorkMode: TWorkMode);
begin
  ProgressBar.Position := 0;
end;

procedure TForm1.HTTPWork(Sender: TObject; AWorkMode: TWorkMode;
  const AWorkCount: Integer);
begin
  ProgressBar.StepBy(AWorkCount);
end;


MfG Bergmann.

_________________
Ich weiß nicht viel, lern aber dafür umso schneller^^
Delphi2009lover Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 176



BeitragVerfasst: Di 24.11.09 14:42 
Mein Problem ist ein ähnliches, so weit war ich aauch mal^^ währ cool wenn da ne Antwort käme^^