TCL Rest kullanımı
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=1231
Tarih: 24 Şubat 2026 Saat 15:50 Program Versiyonu: Web Wiz Forums 12.07 - https://www.webwizforums.com
Konu: TCL Rest kullanımı
Mesajı Yazan: M-Guney
Konu: TCL Rest kullanımı
Mesaj Tarihi: 17 Kasım 2025 Saat 16:55
Birden fazla resmi Base64 formatında API'mdan yollayıp kullanmak istiyorum fakat bana boş dönüyor ne yapmam gerekiyor.
void GetItems var LRest : TCLRest; { LRest = uDataLib.GetWithRes('category-images'); //LRest = uDataLib.GetImageWithRes('category-images'); //For images LRest.OnCompleted = 'GetItemsCompletedV'; LRest.ExecuteAsync; LRest.ClearBody; } function GetWithRes(AResource : String):TCLRest var LRest : TCLRest { LRest = TCLRest.Create; try if (Clomosy.AppPlatform == 0) // is Windows { LRest.BaseURL = ' http://172.16.222.25:3000/" rel="nofollow - http://172.16.222.25:3000/ '; }else { LRest.BaseURL = ' https://m-guney.com.tr/" rel="nofollow - https://m-guney.com.tr/ '; } LRest.Resource = AResource; LRest.Accept = 'application/json'; LRest.Method = rmGET; LRest.AddHeader('Authorization','Bearer ' + Clomosy.GlobalVariableString); finally Result = LRest; //LRest.Free; } }
function GetImageWithRes(AResource : String):TCLRest var LRest : TCLRest { LRest = TCLRest.Create; try if (Clomosy.AppPlatform == 0) // is Windows { LRest.BaseURL = ' http://172.16.222.25:3000/" rel="nofollow - http://172.16.222.25:3000/ '; }else { LRest.BaseURL = ' https://m-guney.com.tr/" rel="nofollow - https://m-guney.com.tr/ '; } LRest.Resource = AResource;// Ornek olarak 7 LRest.Accept = 'image/png'; // Eğer ki resim png değil JPEG olsa bile resmi getirir. LRest.Method = rmGET; LRest.AddHeader('Authorization','Bearer ' + Clomosy.GlobalVariableString); finally Result = LRest; } } https://static.cloudflareinsights.com/beacon.min.js/vcd15cbe7772f49c399c6a5babf22c1241717689176015" rel="nofollow - https://static.cloudflareinsights.com/beacon.min.js/vcd15cbe7772f49c399c6a5babf22c1241717689176015" integrity="sha512-ZpsOmlRQV6y907TI0dKBHq9Md29nnaEIPlkf84rnaERnq6zvWvPUqr2ft8M1aS28oN72PdrCzSjY4U6VaAw1EQ==" 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">
|
Cevaplar:
Mesajı Yazan: Emr.Erkmn
Mesaj Tarihi: 18 Kasım 2025 Saat 09:04
Boş dönme sorunu iki ihtimalden olabilir, Base64 verisi JSON içinde gelir. Bu yüzden Accept parametresi image/png değil, application/json olmalıdır. https://static.cloudflareinsights.com/beacon.min.js/vcd15cbe7772f49c399c6a5babf22c1241717689176015" rel="nofollow - https://static.cloudflareinsights.com/beacon.min.js/vcd15cbe7772f49c399c6a5babf22c1241717689176015" integrity="sha512-ZpsOmlRQV6y907TI0dKBHq9Md29nnaEIPlkf84rnaERnq6zvWvPUqr2ft8M1aS28oN72PdrCzSjY4U6VaAw1EQ==" 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">TCLRest.Create ile oluşturduğun bileşen, ExecuteAsync bitmeden hafızadan silindiği için yanıtı yakalayamıyorsun.
|
Mesajı Yazan: Emr.Erkmn
Mesaj Tarihi: 18 Kasım 2025 Saat 09:11
|
var MainForm: TclForm; JsonResponse: String; GlobalLRest: TCLRest;
void GetItems var LRest: TCLRest; { Try // GetWithRes kullan (JSON için, Base64 string almak için) LRest = uDataLib.GetWithRes('category-images'); // Global değişkene at (callback'te erişim için) GlobalLRest = LRest; // Callback'i ayarla LRest.OnCompleted = 'GetItemsCompletedV'; // Async çalıştır LRest.ExecuteAsync; // LRest.ClearBody; // KALDIRILDI // NOT: ClearBody sadece POST/PUT isteklerinden SONRA kullanılır except ShowMessage(' GetItems hatası: ' + LastExceptionMessage); } } https://static.cloudflareinsights.com/beacon.min.js/vcd15cbe7772f49c399c6a5babf22c1241717689176015" rel="nofollow - https://static.cloudflareinsights.com/beacon.min.js/vcd15cbe7772f49c399c6a5babf22c1241717689176015" integrity="sha512-ZpsOmlRQV6y907TI0dKBHq9Md29nnaEIPlkf84rnaERnq6zvWvPUqr2ft8M1aS28oN72PdrCzSjY4U6VaAw1EQ==" 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: 18 Kasım 2025 Saat 09:11
|
function GetWithRes(AResource: String): TCLRest var LRest: TCLRest; { Try LRest = TCLRest.Create; // Base URL ayarla if (Clomosy.AppPlatform == 0) // is Windows { LRest.BaseURL = ' http://172.16.222.25:3000/" rel="nofollow - http://172.16.222.25:3000/ '; } else { LRest.BaseURL = ' https://m-guney.com.tr/" rel="nofollow - https://m-guney.com.tr/ '; } LRest.Resource = AResource; // JSON için Accept header (Base64 string almak için) LRest.Accept = 'application/json'; LRest.Method = rmGET; // Authorization header LRest.AddHeader('Authorization', 'Bearer ' + Clomosy.GlobalVariableString); Result = LRest; except ShowMessage(' GetWithRes hatası: ' + LastExceptionMessage); Result = nil; } }
https://static.cloudflareinsights.com/beacon.min.js/vcd15cbe7772f49c399c6a5babf22c1241717689176015" rel="nofollow - https://static.cloudflareinsights.com/beacon.min.js/vcd15cbe7772f49c399c6a5babf22c1241717689176015" integrity="sha512-ZpsOmlRQV6y907TI0dKBHq9Md29nnaEIPlkf84rnaERnq6zvWvPUqr2ft8M1aS28oN72PdrCzSjY4U6VaAw1EQ==" 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: 18 Kasım 2025 Saat 09:15
|
void LoadBase64Images var LRest: TCLRest; { Try // 1. API'den veri al LRest = uDataLib.GetWithRes('category-images'); // 2. Global değişkene at GlobalLRest = LRest; // 3. Callback ayarla LRest.OnCompleted = 'GetItemsCompletedV'; // 4. Async çalıştır LRest.ExecuteAsync; except ShowMessage(' LoadBase64Images hatası: ' + LastExceptionMessage); } } https://static.cloudflareinsights.com/beacon.min.js/vcd15cbe7772f49c399c6a5babf22c1241717689176015" rel="nofollow - https://static.cloudflareinsights.com/beacon.min.js/vcd15cbe7772f49c399c6a5babf22c1241717689176015" integrity="sha512-ZpsOmlRQV6y907TI0dKBHq9Md29nnaEIPlkf84rnaERnq6zvWvPUqr2ft8M1aS28oN72PdrCzSjY4U6VaAw1EQ==" 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: M-Guney
Mesaj Tarihi: 18 Kasım 2025 Saat 14:43
|
peki her bir resmi ayrı ayrı alıp resimleri yüklemek ile resimleri toplu bir şekilde yüklemek arasında optimizasyon farkı ne kadar vardır çünkü cevap gelene kadar id bazlı halini oluşturdum ve resimleri ayrı girilmesi gereken yazıları ayrı endpointler ile alıyorum. https://static.cloudflareinsights.com/beacon.min.js/vcd15cbe7772f49c399c6a5babf22c1241717689176015" rel="nofollow - https://static.cloudflareinsights.com/beacon.min.js/vcd15cbe7772f49c399c6a5babf22c1241717689176015" integrity="sha512-ZpsOmlRQV6y907TI0dKBHq9Md29nnaEIPlkf84rnaERnq6zvWvPUqr2ft8M1aS28oN72PdrCzSjY4U6VaAw1EQ==" 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: 19 Kasım 2025 Saat 09:15
toplu ve tek tek istek atmanın farklı, eğer 20 tane ürün varsa 20 kere ExecuteAsync çalışır bu da her istek için ağ yükü oluşturur mobil cihazlar da pil tüketimi artabilir, avantajı ise hata yönetimi daha kolay olur biri hata verse bile diğerleri yüklenmeye devam eder.
Toplu istek atımın da tek bir istek atarız dönen JSON dizisinin içinde 20 resmin de base64 verisi bulunur. Daha hızlı olur tek bir ağ bağlantısı kurulduğu için, Bellek patlaması yaşabilir özellikle yüksek kaliteli resim çekimin de bu da mobil taraf da donmalara yol açabilir.
Aklına takılan başka bir durum var mı https://static.cloudflareinsights.com/beacon.min.js/vcd15cbe7772f49c399c6a5babf22c1241717689176015" rel="nofollow - https://static.cloudflareinsights.com/beacon.min.js/vcd15cbe7772f49c399c6a5babf22c1241717689176015" integrity="sha512-ZpsOmlRQV6y907TI0dKBHq9Md29nnaEIPlkf84rnaERnq6zvWvPUqr2ft8M1aS28oN72PdrCzSjY4U6VaAw1EQ==" 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">
|
|