@@ -102,11 +102,10 @@ procedure TfmMain.btCloneDemoClick(Sender: TObject);
102102 if not GetFile(fname, ftype) then Exit;
103103
104104 curl1 := CurlGet;
105- curl1.SetRecvStream(stream, [csfAutoRewind]);
106- curl1.SetUrl(edUrl.Text);
107- curl1.SetOpt(CURLOPT_POST, true);
108-
109- curl1.Form := CurlGetForm.AddFile(' photo' , fname, ftype);
105+ curl1.SetRecvStream(stream, [csfAutoRewind])
106+ .SetUrl(edUrl.Text)
107+ .SetOpt(CURLOPT_POST, true)
108+ .SetForm(CurlGetForm.AddFile(' photo' , fname, ftype));
110109
111110 curl2 := curl1.Clone;
112111 curl2.Perform;
@@ -123,13 +122,11 @@ procedure TfmMain.btEasyClick(Sender: TObject);
123122 if not GetFile(fname, ftype) then Exit;
124123
125124 curl := CurlGet;
126- curl.SetRecvStream(stream, [csfAutoRewind]);
127- curl.SetUrl(edUrl.Text);
128- curl.SetOpt(CURLOPT_POST, true);
129-
130- curl.Form := CurlGetForm.AddFile(' photo' , fname, ftype);
131-
132- curl.Perform;
125+ curl.SetRecvStream(stream, [csfAutoRewind])
126+ .SetUrl(edUrl.Text)
127+ .SetOpt(CURLOPT_POST, true)
128+ .SetForm(CurlGetForm.AddFile(' photo' , fname, ftype))
129+ .Perform;
133130 memoResponse.Text := UTF8ToString(stream.Data);
134131end ;
135132
@@ -143,17 +140,16 @@ procedure TfmMain.btHardClick(Sender: TObject);
143140 if not GetFile(fname, ftype) then Exit;
144141
145142 curl := CurlGet;
146- curl.SetRecvStream(stream, [csfAutoRewind]);
147- curl.SetUrl(edUrl.Text);
148- curl.SetOpt(CURLOPT_POST, true);
149-
150- curl.Form := CurlGetForm.Add(
143+ curl.SetRecvStream(stream, [csfAutoRewind])
144+ .SetUrl(edUrl.Text)
145+ .SetOpt(CURLOPT_POST, true)
146+ .SetForm(CurlGetForm.Add(
151147 CurlGetField
152148 .Name (' photo' )
153149 .UploadFile(fname)
154- .ContentType(ftype));
150+ .ContentType(ftype)))
151+ .Perform;
155152
156- curl.Perform;
157153 memoResponse.Text := UTF8ToString(stream.Data);
158154end ;
159155
@@ -163,15 +159,13 @@ procedure TfmMain.btSynthMemory2Click(Sender: TObject);
163159begin
164160 // cURL
165161 curl := CurlGet;
166- curl.SetRecvStream(stream, [csfAutoRewind]);
167- curl.SetUrl(edUrl.Text);
168- curl.SetOpt(CURLOPT_POST, true);
169-
170- curl.Form := CurlGetForm.AddFileBuffer(
162+ curl.SetRecvStream(stream, [csfAutoRewind])
163+ .SetUrl(edUrl.Text)
164+ .SetOpt(CURLOPT_POST, true)
165+ .SetForm(CurlGetForm.AddFileBuffer(
171166 ' photo' , ' synth_buffer2.png' , ' image/png' ,
172- pngStream.Size, pngStream.Memory^);
173-
174- curl.Perform;
167+ pngStream.Size, pngStream.Memory^))
168+ .Perform;
175169 memoResponse.Text := UTF8ToString(stream.Data);
176170end ;
177171
@@ -184,14 +178,12 @@ procedure TfmMain.btSynthMemory3Click(Sender: TObject);
184178 Move(pngStream.Memory^, PAnsiChar(str)^, pngStream.Size);
185179 // cURL
186180 curl := CurlGet;
187- curl.SetRecvStream(stream, [csfAutoRewind]);
188- curl.SetUrl(edUrl.Text);
189- curl.SetOpt(CURLOPT_POST, true);
190-
191- curl.Form := CurlGetForm.AddFileBuffer(
192- ' photo' , ' synth_buffer3.png' , ' image/png' , str);
193-
194- curl.Perform;
181+ curl.SetRecvStream(stream, [csfAutoRewind])
182+ .SetUrl(edUrl.Text)
183+ .SetOpt(CURLOPT_POST, true)
184+ .SetForm(CurlGetForm.AddFileBuffer(
185+ ' photo' , ' synth_buffer3.png' , ' image/png' , str))
186+ .Perform;
195187 memoResponse.Text := UTF8ToString(stream.Data);
196188end ;
197189
@@ -201,18 +193,16 @@ procedure TfmMain.btSynthMemoryClick(Sender: TObject);
201193begin
202194 // cURL
203195 curl := CurlGet;
204- curl.SetRecvStream(stream, [csfAutoRewind]);
205- curl.SetUrl(edUrl.Text);
206- curl.SetOpt(CURLOPT_POST, true);
207-
208- curl.Form := CurlGetForm.Add(
196+ curl.SetRecvStream(stream, [csfAutoRewind])
197+ .SetUrl(edUrl.Text)
198+ .SetOpt(CURLOPT_POST, true)
199+ .SetForm(CurlGetForm.Add(
209200 CurlGetField
210201 .Name (' photo' )
211202 .FileBuffer(
212203 ' synth_buffer.png' , pngStream.Size, pngStream.Memory^)
213- .ContentType(' image/png' ));
214-
215- curl.Perform;
204+ .ContentType(' image/png' )))
205+ .Perform;
216206 memoResponse.Text := UTF8ToString(stream.Data);
217207end ;
218208
@@ -225,18 +215,16 @@ procedure TfmMain.btSynthStreamClick(Sender: TObject);
225215
226216 // cURL
227217 curl := CurlGet;
228- curl.SetRecvStream(stream, [csfAutoRewind]);
229- curl.SetUrl(edUrl.Text);
230- curl.SetOpt(CURLOPT_POST, true);
231-
232- curl.Form := CurlGetForm.Add(
218+ curl.SetRecvStream(stream, [csfAutoRewind])
219+ .SetUrl(edUrl.Text)
220+ .SetOpt(CURLOPT_POST, true)
221+ .SetForm( CurlGetForm.Add(
233222 CurlGetField
234223 .Name (' photo' )
235224 .FileStream(pngStream, [csfAutoRewind])
236225 .ContentType(' image/png' )
237- .FileName(' synth_stream.png' ));
238-
239- curl.Perform;
226+ .FileName(' synth_stream.png' )))
227+ .Perform;
240228 memoResponse.Text := UTF8ToString(stream.Data);
241229end ;
242230
0 commit comments