uese
IdHTTP; //
...
procedure TfrmSelvas.btnSaveClick(Sender: TObject);
var
IDhttp: TIdHTTP;
TRequest : TstringStream;
TOut : TstringStream;
URL, sString : String;
begin
try
IDhttp := TIdHTTP.Create(nil);
URL := 'http://localhost:8080/pierrot/api';
TRequest := TStringStream.Create('');
TOut := TStringStream.Create('');
IDhttp.ConnectTimeout := 3000;
IDhttp.ReadTimeout := 3000;
IDhttp.Request.ContentType := 'application/json;charset=UTF-8';
TRequest.Clear;
TOut.Clear;
sString := '';
sString := '{ '+#13#10+
' "FileName": "Pierrot.pdf", '+#13#10+
' "Dir": "C:\dir" '+#13#10+
'} ';
TRequest.WriteString(sString);
TRequest.Position := 0;
IDhttp.Post(URL, TRequest, TOut);
TOut.SaveToFile('C:\pierrot.pdf');
finally
IDhttp.Free;
TRequest.Free;
TOut.Free;
end;
end;
DELPHi TIdHTTP JSON 格式 POST 读取 二进制文件
最新推荐文章于 2024-07-29 09:10:44 发布