Registriert seit: 13. Feb 2006
Ort: Kempten
253 Beiträge
|
Re: idHTTP: MemoryStream POSTen
24. Mär 2007, 13:19
Keiner ne Ahnung?
Hier mal mein Code, aber der wird auch nicht mehr sagen:
Delphi-Quellcode:
procedure TForm1.Button1Click(Sender: TObject);
var
Stream1,
Stream2: TMemoryStream;
Start,
Laenge,
i: Integer;
Fil: string;
begin
if OpenDialog1.Execute then
begin
Stream1 := TMemoryStream.Create;
Stream2 := TMemoryStream.Create;
Stream1.LoadFromFile(OpenDialog1.FileName);
SetLength(Fil, Stream1.Size);
Stream1.Read(PChar(Fil)^, Stream1.Size);
Start := 1;
i := 0;
// while Start < Stream1.Size do // zum debuggen auskommentiert, geht schneller so ;)
begin
Inc(i);
Form1.Caption := IntToStr(i) + '/' + IntToStr(Round(Stream1.Size / 921600));
if Start + 921600 > Stream1.Size then
Laenge := Stream1.Size - Start
else
begin
Laenge := 921603 + Pos(';', PChar(Fil) + Start + 921600);
if Start + Laenge > Stream1.Size then Laenge := Stream1.Size - Start;
end;
Stream2.Clear;
Stream2.Write('lang=de-utf-8'#13#10'server=1'#13#10'collation_connection=utf8_general_ci'#13#10'goto=db_details.php'#13#10'show_query=0'#13#10'sql_query=', 104);
Stream2.Write(Fil[Start], Laenge);
if CheckBox1.Checked then
begin
IdHTTP1.Request.Username := Edit2.Text;
IdHTTP1.Request.Password := Edit3.Text;
Stream1.Clear;
IdHTTP1.Post(Edit1.Text + 'read_dump.php', Stream2, Stream1); //
Stream1.SaveToFile('test.htm'); // Stream1 wird zum debuggen für die Ausgabe missbraucht
end
else
Stream2.SaveToFile(Copy(OpenDialog1.FileName, 0, length(OpenDialog1.FileName) - length(ExtractFileExt(OpenDialog1.FileName))) + ' ' + IntToStr(i) + '.sql');
Start := Start + Laenge;
end;
Form1.Caption := 'fertig';
end;
end;
"Conspiracy is the poor man's mapping of the world" - Fredric Jameson
|
|
Zitat
|