Clomosy | Forum Ana Sayfa
Forum Anasayfa Forum Anasayfa > Genel Programlama > Clomosy ile değişken kullanımı
  Aktif Konular Aktif Konular RSS - Görsel Api İle Web e Gönderme
  SSS SSS  Forumu Ara   Etkinlikler   Kayıt Ol Kayıt Ol  Giriş Giriş

Clomosy Resmi Forum Sitesidir. Amacımız kullanıcılarımıza, iş ortaklarımıza, danışmanlara, yazılımcılara programlarımız hakkında destek ve bilgi vermektir.

Görsel Api İle Web e Gönderme

 Yanıt Yaz Yanıt Yaz
Yazar
Mesaj
  Konu Arama Konu Arama  Topic Seçenekleri Topic Seçenekleri
Hüseyin_Sadik Açılır Kutu İzle
Yeni Üye
Yeni Üye
Simge

Kayıt Tarihi: 03 Aralık 2025
Durum: Aktif Değil
Puanlar: 27
Mesaj Seçenekleri Mesaj Seçenekleri   Teşekkürler (0) Teşekkürler(0)   Alıntı Hüseyin_Sadik Alıntı  Yanıt YazCevapla Mesajın Direkt Linki Konu: Görsel Api İle Web e Gönderme
    Gönderim Zamanı: 5 Saat 30 Dakika Önce Saat 10:29
Clomosy'de herhangi bir projede görseli api ile nasıl web e gönderilebilir.
Yukarı Dön
Emr.Erkmn Açılır Kutu İzle
Moderatör
Moderatör


Kayıt Tarihi: 28 Şubat 2025
Durum: Aktif Değil
Puanlar: 950
Mesaj Seçenekleri Mesaj Seçenekleri   Teşekkürler (0) Teşekkürler(0)   Alıntı Emr.Erkmn Alıntı  Yanıt YazCevapla Mesajın Direkt Linki Gönderim Zamanı: 5 Saat 25 Dakika Önce 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 + '"}';
    
    
    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



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">
Yukarı Dön
Emr.Erkmn Açılır Kutu İzle
Moderatör
Moderatör


Kayıt Tarihi: 28 Şubat 2025
Durum: Aktif Değil
Puanlar: 950
Mesaj Seçenekleri Mesaj Seçenekleri   Teşekkürler (0) Teşekkürler(0)   Alıntı Emr.Erkmn Alıntı  Yanıt YazCevapla Mesajın Direkt Linki Gönderim Zamanı: 1 saat 46 Dakika Önce 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 + '"}';
    
    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" 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">
Yukarı Dön
 Yanıt Yaz Yanıt Yaz

Forum Atla Forum İzinleri Açılır Kutu İzle

Forum Software by Web Wiz Forums® version 12.07
Copyright ©2001-2024 Web Wiz Ltd.

Bu Sayfa 0,016 Saniyede Yüklendi.