Gyazo 1.0.0
dotnet add package Gyazo --version 1.0.0
NuGet\Install-Package Gyazo -Version 1.0.0
<PackageReference Include="Gyazo" Version="1.0.0" />
paket add Gyazo --version 1.0.0
#r "nuget: Gyazo, 1.0.0"
// Install Gyazo as a Cake Addin #addin nuget:?package=Gyazo&version=1.0.0 // Install Gyazo as a Cake Tool #tool nuget:?package=Gyazo&version=1.0.0
Gyazo.NET
Gyazo API client for .NET and Unity.
English | 日本語
Overview
Gyazo.NET is a client SDK for the Gyazo API for .NET.
Installation
Gyazo.NET is distributed via NuGet and supports .NET Standard 2.1, .NET 6.0, and .NET 8.0.
.NET CLI
dotnet add package Gyazo
Package Manager
Install-Package Gyazo
Additionally, Gyazo.NET can be used with Unity. See the Unity section for details.
Usage
You can call the Gyazo API using GyazoClient
.
using System.IO;
using Gyazo;
using var client = new GyazoClient
{
AccessToken = Environment.GetEnvironmentVariable("GYAZO_TOKEN") // Default
};
// Read the image file
var image = await File.ReadAllBytesAsync("image.png");
// Upload the image
var response = await client.Images.UploadAsync(new()
{
ImageData = image,
});
// Get the image URL
Console.WriteLine(response.PermanentLinkUrl);
GyazoClient
supports API calls for both Image and Users. For more details, refer to the official API reference.
Exception Handling
If an API call fails, a GyazoApiException
will be thrown.
try
{
var response = await client.Images.GetAsync(new()
{
ImageId = "...",
});
}
catch (GyazoApiException ex)
{
Console.WriteLine((int)ex.Status); // 401 (ErrorCode.AuthenticationError)
Console.WriteLine(ex.Message); // You are not authorized.
}
Customizing HttpClient
GyazoClient
uses the standard HttpClient
for communication. If you want to adjust the behavior of HttpClient, you can pass an HttpClientHandler
during its creation.
public class GyazoClient : IDisposable
{
readonly HttpClient httpClient;
public HttpClient HttpClient => httpClient;
public GyazoClient(HttpMessageHandler handler, bool disposeHandler)
{
httpClient = new(handler, disposeHandler);
}
public GyazoClient()
: this(new HttpClientHandler(), true)
{
}
public GyazoClient(HttpMessageHandler handler)
: this(handler, true)
{
}
public void Dispose()
{
httpClient.Dispose();
}
}
Unity
Gyazo.NET can be used with Unity. To install Gyazo.NET in Unity, use [NugetForUnity].
- Install NugetForUnity
- Open the Nuget > Manage NuGet Packages window, search for Gyazo, and install it
When using it in environments like WebGL, you need to replace the communication layer with UnityWebRequest. Here is an example using UnityWebRequestHttpMessageHandler.cs.
// Change HttpClientHandler to UnityWebRequestHttpMessageHandler
var client = new GyazoClient(new UnityWebRequestHttpMessageHandler())
{
AccessToken = "YOUR_ACCESS_TOKEN",
ConfigureAwait = true // Set ConfigureAwait to true for safe operation in WebGL
};
License
This library is distributed under the MIT License.
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net5.0 was computed. net5.0-windows was computed. net6.0 is compatible. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 was computed. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 is compatible. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. |
.NET Core | netcoreapp3.0 was computed. netcoreapp3.1 was computed. |
.NET Standard | netstandard2.1 is compatible. |
MonoAndroid | monoandroid was computed. |
MonoMac | monomac was computed. |
MonoTouch | monotouch was computed. |
Tizen | tizen60 was computed. |
Xamarin.iOS | xamarinios was computed. |
Xamarin.Mac | xamarinmac was computed. |
Xamarin.TVOS | xamarintvos was computed. |
Xamarin.WatchOS | xamarinwatchos was computed. |
-
.NETStandard 2.1
- System.Net.Http.Json (>= 8.0.0)
- System.Text.Json (>= 8.0.0)
-
net6.0
- System.Net.Http.Json (>= 8.0.0)
- System.Text.Json (>= 8.0.0)
-
net8.0
- No dependencies.
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
Version | Downloads | Last updated |
---|---|---|
1.0.0 | 96 | 6/24/2024 |