From 0b16a55693b661d843f6b62b252769c83fe4ed14 Mon Sep 17 00:00:00 2001 From: iminet Date: Fri, 6 Mar 2026 13:55:39 +0100 Subject: [PATCH] Added ability for uploading Base64 content --- ImgBBApi.cs | 7 ++++++- ImgBBApi.csproj | 16 ++++++++-------- 2 files changed, 14 insertions(+), 9 deletions(-) diff --git a/ImgBBApi.cs b/ImgBBApi.cs index fbaccb7..ee8340f 100644 --- a/ImgBBApi.cs +++ b/ImgBBApi.cs @@ -29,7 +29,12 @@ namespace Iminetsoft /* SORGU GONDERDIK VE JSON RESPONSE-U ELDE ETDIK: */ string requestUrl = $"https://api.imgbb.com/1/upload?key={ApiKey}"; MultipartFormDataContent content = new MultipartFormDataContent(); - string base64OfImage = Convert.ToBase64String(File.ReadAllBytes(imagePath)); + + // Temporary solution + string base64OfImage = File.Exists(imagePath) ? Convert.ToBase64String(File.ReadAllBytes(imagePath)) + : imagePath.Trim(); + + content.Add(new StringContent(base64OfImage), "image"); content.Add(new StringContent(Path.GetFileNameWithoutExtension(imagePath)), "name"); HttpRequestMessage request = new HttpRequestMessage(HttpMethod.Post, requestUrl) { Content = content }; diff --git a/ImgBBApi.csproj b/ImgBBApi.csproj index 4cdfc20..cb04552 100644 --- a/ImgBBApi.csproj +++ b/ImgBBApi.csproj @@ -1,14 +1,15 @@  - net5.0;net6.0 - disable - Library + net5.0;net6.0;net7.0;net8.0 + disable + Library ImgBBApi ImgBBApi Added package icon - 1.0.2 - 1.0.2 - 1.0.2 + False + 1.0.3 + $(AssemblyVersion) + $(AssemblyVersion) iminet C# library for ImgBB Iminetsoft.ImgBBApi @@ -20,9 +21,8 @@ C# library for ImgBB false true - false + false -