Added ability for uploading Base64 content

This commit is contained in:
iminet
2026-03-06 13:55:39 +01:00
parent 545a4b29eb
commit 0b16a55693
2 changed files with 14 additions and 9 deletions

View File

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

View File

@@ -1,14 +1,15 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFrameworks>net5.0;net6.0</TargetFrameworks>
<Nullable>disable</Nullable>
<OutputType>Library</OutputType>
<TargetFrameworks>net5.0;net6.0;net7.0;net8.0</TargetFrameworks>
<Nullable>disable</Nullable>
<OutputType>Library</OutputType>
<RootNamespace>ImgBBApi</RootNamespace>
<AssemblyName>ImgBBApi</AssemblyName>
<PackageReleaseNotes>Added package icon</PackageReleaseNotes>
<Version>1.0.2</Version>
<AssemblyVersion>1.0.2</AssemblyVersion>
<FileVersion>1.0.2</FileVersion>
<Deterministic>False</Deterministic>
<AssemblyVersion>1.0.3</AssemblyVersion>
<Version>$(AssemblyVersion)</Version>
<FileVersion>$(AssemblyVersion)</FileVersion>
<Authors>iminet</Authors>
<Product>C# library for ImgBB</Product>
<PackageId>Iminetsoft.ImgBBApi</PackageId>
@@ -20,9 +21,8 @@
<Description>C# library for ImgBB</Description>
<GenerateAssemblyInfo>false</GenerateAssemblyInfo>
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
<CheckEolTargetFramework>false</CheckEolTargetFramework>
<CheckEolTargetFramework>false</CheckEolTargetFramework>
</PropertyGroup>
<ItemGroup>
<None Include="Readme.md" Pack="true" PackagePath="\"></None>
<None Include="Resources\imgbb.png" Pack="true" PackagePath="\"></None>