mirror of
https://github.com/iminet/ImgBBApi.git
synced 2026-03-15 18:18:08 +01:00
Added ability for uploading Base64 content
This commit is contained in:
@@ -29,7 +29,12 @@ namespace Iminetsoft
|
|||||||
/* SORGU GONDERDIK VE JSON RESPONSE-U ELDE ETDIK: */
|
/* SORGU GONDERDIK VE JSON RESPONSE-U ELDE ETDIK: */
|
||||||
string requestUrl = $"https://api.imgbb.com/1/upload?key={ApiKey}";
|
string requestUrl = $"https://api.imgbb.com/1/upload?key={ApiKey}";
|
||||||
MultipartFormDataContent content = new MultipartFormDataContent();
|
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(base64OfImage), "image");
|
||||||
content.Add(new StringContent(Path.GetFileNameWithoutExtension(imagePath)), "name");
|
content.Add(new StringContent(Path.GetFileNameWithoutExtension(imagePath)), "name");
|
||||||
HttpRequestMessage request = new HttpRequestMessage(HttpMethod.Post, requestUrl) { Content = content };
|
HttpRequestMessage request = new HttpRequestMessage(HttpMethod.Post, requestUrl) { Content = content };
|
||||||
|
|||||||
@@ -1,14 +1,15 @@
|
|||||||
<Project Sdk="Microsoft.NET.Sdk">
|
<Project Sdk="Microsoft.NET.Sdk">
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<TargetFrameworks>net5.0;net6.0</TargetFrameworks>
|
<TargetFrameworks>net5.0;net6.0;net7.0;net8.0</TargetFrameworks>
|
||||||
<Nullable>disable</Nullable>
|
<Nullable>disable</Nullable>
|
||||||
<OutputType>Library</OutputType>
|
<OutputType>Library</OutputType>
|
||||||
<RootNamespace>ImgBBApi</RootNamespace>
|
<RootNamespace>ImgBBApi</RootNamespace>
|
||||||
<AssemblyName>ImgBBApi</AssemblyName>
|
<AssemblyName>ImgBBApi</AssemblyName>
|
||||||
<PackageReleaseNotes>Added package icon</PackageReleaseNotes>
|
<PackageReleaseNotes>Added package icon</PackageReleaseNotes>
|
||||||
<Version>1.0.2</Version>
|
<Deterministic>False</Deterministic>
|
||||||
<AssemblyVersion>1.0.2</AssemblyVersion>
|
<AssemblyVersion>1.0.3</AssemblyVersion>
|
||||||
<FileVersion>1.0.2</FileVersion>
|
<Version>$(AssemblyVersion)</Version>
|
||||||
|
<FileVersion>$(AssemblyVersion)</FileVersion>
|
||||||
<Authors>iminet</Authors>
|
<Authors>iminet</Authors>
|
||||||
<Product>C# library for ImgBB</Product>
|
<Product>C# library for ImgBB</Product>
|
||||||
<PackageId>Iminetsoft.ImgBBApi</PackageId>
|
<PackageId>Iminetsoft.ImgBBApi</PackageId>
|
||||||
@@ -20,9 +21,8 @@
|
|||||||
<Description>C# library for ImgBB</Description>
|
<Description>C# library for ImgBB</Description>
|
||||||
<GenerateAssemblyInfo>false</GenerateAssemblyInfo>
|
<GenerateAssemblyInfo>false</GenerateAssemblyInfo>
|
||||||
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
|
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
|
||||||
<CheckEolTargetFramework>false</CheckEolTargetFramework>
|
<CheckEolTargetFramework>false</CheckEolTargetFramework>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<None Include="Readme.md" Pack="true" PackagePath="\"></None>
|
<None Include="Readme.md" Pack="true" PackagePath="\"></None>
|
||||||
<None Include="Resources\imgbb.png" Pack="true" PackagePath="\"></None>
|
<None Include="Resources\imgbb.png" Pack="true" PackagePath="\"></None>
|
||||||
|
|||||||
Reference in New Issue
Block a user