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: */
|
||||
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 };
|
||||
|
||||
@@ -1,14 +1,15 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
<PropertyGroup>
|
||||
<TargetFrameworks>net5.0;net6.0</TargetFrameworks>
|
||||
<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>
|
||||
@@ -22,7 +23,6 @@
|
||||
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
|
||||
<CheckEolTargetFramework>false</CheckEolTargetFramework>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<None Include="Readme.md" Pack="true" PackagePath="\"></None>
|
||||
<None Include="Resources\imgbb.png" Pack="true" PackagePath="\"></None>
|
||||
|
||||
Reference in New Issue
Block a user