Merhaba Hüseyin
seçilen görseli rest api servisine göndermek için görseli base64 formatına dönüştürüp bir json gövdesi içierisinde post etmen gerekli
aşağıda bir örnek bırakıyorum
var AnaForm: TclForm; KapsayiciPnl: TclProPanel; SecilenGorsel: TclProImage; BtnGorselSec: TclProButton; BtnWebGonder: TclProButton; GlobalRest: TclRest;
void OnApiResponseCompleted; { try if (GlobalRest.Response <> '') { ShowMessage('Görsel başarıyla web sunucusuna gönderildi! Sunucu Yanıtı: ' + GlobalRest.Response); } else { ShowMessage('Görsel gönderildi fakat sunucudan boş yanıt döndü.'); } GlobalRest.Free; except ShowMessage('Yükleme yanıtı işleme hatası: ' + LastExceptionMessage); } }
void OnGorselSecClick; { Clomosy.ImageChooser(AnaForm, SecilenGorsel); }
void OnWebGonderClick; var LBase64Veri: String; LJsonGovde: String; LWebUrl: String; { if (SecilenGorsel.clProSettings.PictureSource == '') { ShowMessage('Lütfen önce gönderilecek bir görsel seçiniz!'); Exit; }
try LBase64Veri = Clomosy.FileToBase64(SecilenGorsel.clProSettings.PictureSource); LJsonGovde = '{"image_name":"mobil_gorsel.jpg", "image_data":"' + LBase64Veri + '"}'; LWebUrl = ' https://sizin-web-servisiniz.com/api/upload" rel="nofollow - https://sizin-web-servisiniz.com/api/upload '; GlobalRest = TclRest.Create; GlobalRest.BaseURL = LWebUrl; GlobalRest.Method = rmPOST; GlobalRest.Accept = 'application/json'; GlobalRest.AddBody(LJsonGovde, 'application/json'); GlobalRest.OnCompleted = 'OnApiResponseCompleted'; GlobalRest.ExecuteAsync; ShowMessage('Görsel arka planda web sunucusuna yükleniyor, lütfen bekleyiniz...'); except ShowMessage('Görsel dönüştürme veya API hatası: ' + LastExceptionMessage); } }
{ AnaForm = TclForm.Create(Self); AnaForm.clSetCaption('API Görsel Gönderimi'); AnaForm.SetFormColor('#1e1e2e', '#1e1e2e', clGNone);
KapsayiciPnl = AnaForm.AddNewProPanel(AnaForm, 'KapsayiciPnl'); KapsayiciPnl.Align = alClient; KapsayiciPnl.Margins.Left = 20; KapsayiciPnl.Margins.Right = 20; KapsayiciPnl.Margins.Top = 20; KapsayiciPnl.Margins.Bottom = 20; KapsayiciPnl.clProSettings.BackgroundColor = clAlphaColor.clHexToColor('#2e2e3e'); KapsayiciPnl.clProSettings.RoundHeight = 12; KapsayiciPnl.clProSettings.RoundWidth = 12; KapsayiciPnl.SetclProSettings(KapsayiciPnl.clProSettings);
SecilenGorsel = AnaForm.AddNewProImage(KapsayiciPnl, 'SecilenGorsel'); SecilenGorsel.Align = alTop; SecilenGorsel.Height = 250; SecilenGorsel.Margins.Top = 15; SecilenGorsel.Margins.Left = 15; SecilenGorsel.Margins.Right = 15; SecilenGorsel.clProSettings.PictureAutoFit = True; SecilenGorsel.clProSettings.RoundHeight = 8; SecilenGorsel.clProSettings.RoundWidth = 8; SecilenGorsel.SetclProSettings(SecilenGorsel.clProSettings);
BtnGorselSec = AnaForm.AddNewProButton(KapsayiciPnl, 'BtnGorselSec', '📸 GÖRSEL SEÇ / ÇEK'); BtnGorselSec.Align = alTop; BtnGorselSec.Height = 45; BtnGorselSec.Margins.Top = 20; BtnGorselSec.clProSettings.BackgroundColor = clAlphaColor.clHexToColor('#3B82F6'); BtnGorselSec.clProSettings.FontColor = clAlphaColor.clWhite; BtnGorselSec.clProSettings.TextSettings.Font.Style = [fsBold]; BtnGorselSec.clProSettings.RoundHeight = 8; BtnGorselSec.clProSettings.RoundWidth = 8; BtnGorselSec.SetclProSettings(BtnGorselSec.clProSettings); AnaForm.AddNewEvent(BtnGorselSec, tbeOnClick, 'OnGorselSecClick');
BtnWebGonder = AnaForm.AddNewProButton(KapsayiciPnl, 'BtnWebGonder', '🌐 WEB''E API İLE GÖNDER'); BtnWebGonder.Align = alTop; BtnWebGonder.Height = 45; BtnWebGonder.Margins.Top = 15; BtnWebGonder.clProSettings.BackgroundColor = clAlphaColor.clHexToColor('#10B981'); BtnWebGonder.clProSettings.FontColor = clAlphaColor.clWhite; BtnWebGonder.clProSettings.TextSettings.Font.Style = [fsBold]; BtnWebGonder.clProSettings.RoundHeight = 8; BtnWebGonder.clProSettings.RoundWidth = 8; BtnWebGonder.SetclProSettings(BtnWebGonder.clProSettings); AnaForm.AddNewEvent(BtnWebGonder, tbeOnClick, 'OnWebGonderClick');
AnaForm.FormWaiting.Visible = False; AnaForm.BtnFormMenu.Visible = False; AnaForm.BtnGoBack.Visible = False;
AnaForm.Run; } burada gerekli kullanman gereken https://www.docs.clomosy.com/FileToBase64" rel="nofollow - https://www.docs.clomosy.com/FileToBase64
https://static.cloudflareinsights.com/beacon.min.js/v4513226cdae34746b4dedf0b4dfa099e1781791509496" rel="nofollow - https://static.cloudflareinsights.com/beacon.min.js/v4513226cdae34746b4dedf0b4dfa099e1781791509496" integrity="sha512-ZE9pZaUXND66v380QUtch/5sE9tPFh2zg45pR2PB0CVkCtOREv2AJKkSidISWkysEuQ0EH8faUU5du78bx87UQ==" data-cf-beacon="{"version":"2024.11.0","token":"439455f3e46c40b98dbd42a2f1a954d8","r":1,"server_timing":{"name":{"cfCacheStatus":true,"cfEdge":true,"cfExtPri":true,"cfL4":true,"cfOrigin":true,"cfSpeedBrain":true},"location_startswith":null}}" crossorigin="anonymous">
|