Gyazo 1.0.0

dotnet add package Gyazo --version 1.0.0                
NuGet\Install-Package Gyazo -Version 1.0.0                
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Gyazo" Version="1.0.0" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add Gyazo --version 1.0.0                
#r "nuget: Gyazo, 1.0.0"                
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// 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.

NuGet Releases GitHub license

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].

  1. Install NugetForUnity
  2. 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 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. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

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 74 6/24/2024