Categorygithub.com/codedius/imagekit-go
repositorypackage
1.1.3
Repository: https://github.com/codedius/imagekit-go.git
Documentation: pkg.go.dev

# README

imagekit-go

A Go client library for accessing the ImageKit.io API.

Installation

Use the following command to download this module:

go get github.com/codedius/imagekit-go

Usage

import "github.com/codedius/imagekit-go"

Construct a new API client, then use to access the ImageKit.io API. For example:

opts := imagekit.Options{
    PublicKey:  "Your API Private Key",
    PrivateKey: "Your API Public Key",
}

ik, err := imagekit.NewClient(&opts)
if err != nil {
    // error handling
}

Upload image to your ImageKit.io Media Library:

ur := imagekit.UploadRequest{
    File:              file, // []byte OR *url.URL OR url.URL OR base64 string
    FileName:          "file name",
    UseUniqueFileName: false,
    Tags:              []string{},
    Folder:            "/",
    IsPrivateFile:     false,
    CustomCoordinates: "",
    ResponseFields:    nil,
}

ctx := context.Background()

upr, err := ik.Upload.ServerUpload(ctx, &ur)
if err != nil {
    // error handling
}

Other methods are pretty straightforward and doesn't need extra explanations. For more info please read library's documentation from go.dev and ImageKit.io API documentation.