Sayfayı Yazdır | Pencereyi Kapat

Görsel Api İle Web e Gönderme

Nereden Yazdırıldığı: Clomosy | Forum
Kategori: Genel Programlama
Forum Adı: Clomosy ile değişken kullanımı
Forum Tanımlaması: TRObject dili ile değişken tanımlaması ve ekranda gösterme
URL: https://forum.clomosy.com.tr/forum_posts.asp?TID=1584
Tarih: 03 Temmuz 2026 Saat 14:17
Program Versiyonu: Web Wiz Forums 12.07 - https://www.webwizforums.com


Konu: Görsel Api İle Web e Gönderme
Mesajı Yazan: Hüseyin_Sadik
Konu: Görsel Api İle Web e Gönderme
Mesaj Tarihi: 03 Temmuz 2026 Saat 10:29
Clomosy'de herhangi bir projede görseli api ile nasıl web e gönderilebilir.



Cevaplar:
Mesajı Yazan: Emr.Erkmn
Mesaj Tarihi: 03 Temmuz 2026 Saat 10:34
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">


Mesajı Yazan: Emr.Erkmn
Mesaj Tarihi: 03 Temmuz 2026 Saat 14:13
var
  AnaForm: TclForm;
  KapsayiciPnl: TclProPanel;
  SecilenGorsel: TclImage;
  BtnGorselSec: TclProButton;
  BtnWebGonder: TclProButton;

void OnGorselSecClick;
{
  Clomosy.ImageChooser(AnaForm, SecilenGorsel);
}

void OnWebGonderClick;
var
  LBase64Veri: String;
  LJsonGovde: String;
  LWebUrl: String;
  LRest: TclRest;
  LMemStream: TCLMemoryStream;
{
  LMemStream = TCLMemoryStream.Create;
  try
    SecilenGorsel.Bitmap.SaveToStream(LMemStream);
    
    if (LMemStream.Size == 0)
    {
      ShowMessage('Lütfen önce gönderilecek bir görsel seçiniz!');
      Exit;
    }
    
    LBase64Veri = LMemStream.AsBase64;
    
    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 ';
    
    LRest = TclRest.Create;
    try
      LRest.BaseURL = LWebUrl;
      LRest.Method = rmPOST;
      LRest.Accept = 'application/json';
      LRest.AddBody(LJsonGovde, 'application/json');
      
      LRest.Execute;
      
      if (LRest.Response <> '')
      {
        ShowMessage('Görsel başarıyla gönderildi! Sunucu Yanıtı: ' + LRest.Response);
      }
      else
      {
        ShowMessage('Görsel gönderildi fakat sunucudan boş yanıt döndü.');
      }
    finally
      LRest.Free;
    }
    
  finally
    LMemStream.Free;
  }
}

{
  AnaForm = TclForm.Create(Self);
  AnaForm.clSetCaption('TclImage ile 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.AddNewImage(KapsayiciPnl, 'SecilenGorsel');
  SecilenGorsel.Align = alTop;
  SecilenGorsel.Height = 250;
  SecilenGorsel.Margins.Top = 15; SecilenGorsel.Margins.Left = 15; SecilenGorsel.Margins.Right = 15;

  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;
}
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">



Sayfayı Yazdır | Pencereyi Kapat

Forum Software by Web Wiz Forums® version 12.07 - https://www.webwizforums.com
Copyright ©2001-2024 Web Wiz Ltd. - https://www.webwiz.net