Autor Beitrag
FriFra
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 557

Win XP Prof, Win XP Home,Win Server 2003,Win 98SE,Win 2000,Win NT4,Win 3.11,Suse Linux 7.3 Prof,Suse Linux 8.0 Prof
D2k5 Prof, D7 Prof, D5 Standard, D3 Prof, K3 Prof
BeitragVerfasst: Sa 31.01.04 23:48 
Kann man Bilder aus Resourcen irgendwie direkt über den IdHTTPServer ausgeben? Ich habe es nicht hinbekommen den ResourceStream direkt an die Server-Compo zu übergeben, statt dessen speichere ich den Stream temporär und gebe die Datei dann über ServeFile weiter... das sollte doch auch eleganter gehen?

ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
if ARequestInfo.Document = '/gif/logo' then
begin
  AResponseInfo.ContentType := 'image/gif';
  try
    RS := TResourceStream.Create(0, 'logo', RT_RCDATA);
    RS.Position := 0;
    TmpFile := GetTempFile;
    RS.SaveToFile(TmpFile);
    IdHTTPServer1.ServeFile(AThread, AResponseInfo, TmpFile);
    try
      DeleteFile(TmpFile);
    except
    end;
  finally
    RS.Free;
  end;
end;

_________________
Michael
(principal certified lotus professional - developer)
Ex0rzist
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 550

Win XP Prof.
Mandrake 10.0

D6
BeitragVerfasst: So 01.02.04 02:31 
Mit AThread.Connection.WriteStream(RS); kannst du den Stream senden. Allerdings musst du dann den HTTP-Header extra senden. Der wird dabei nämlich nicht automatisch verschickt.

_________________
If accidentally read, induce vomitting.
FriFra Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 557

Win XP Prof, Win XP Home,Win Server 2003,Win 98SE,Win 2000,Win NT4,Win 3.11,Suse Linux 7.3 Prof,Suse Linux 8.0 Prof
D2k5 Prof, D7 Prof, D5 Standard, D3 Prof, K3 Prof
BeitragVerfasst: So 01.02.04 02:41 
Aber wo gebe ich dann RS frei?

_________________
Michael
(principal certified lotus professional - developer)
Ex0rzist
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 550

Win XP Prof.
Mandrake 10.0

D6
BeitragVerfasst: So 01.02.04 14:53 
Gute Frage. :?

Das ist bei der Komponente wohl nicht vorgesehen.
Bei den Sockets gibt es die tolle Funktion SendStreamThenDrop. Die wäre ideal hierfür gewesen.
In der Hilfe steht, dass nach dem Schreiben des Streams OnWorkEnd aufgerufen wird. Vielleicht hilft dir das weiter?

_________________
If accidentally read, induce vomitting.