imagekit

package module
v0.1.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 29, 2022 License: MIT Imports: 12 Imported by: 0

README

imagekit-go

An ImageKit.io SDK for Golang.

Documentation

Index

Constants

View Source
const (
	BASE_URL        = "https://api.imagekit.io/v1"
	UPLOAD_URL      = "https://upload.imagekit.io/api/v1/files/upload"
	MIN_LIMIT_VALUE = 1
	MIN_SKIP_VALUE  = 0
	MAX_LIMIT_VALUE = 1000
)

Variables

View Source
var VALID_FILE_TYPES = []string{"all", "image", "non-image"}
View Source
var VALID_SORT_FIELDS = []string{
	"ASC_NAME",
	"DESC_NAME",
	"ASC_CREATED",
	"DESC_CREATED",
	"ASC_UPDATED",
	"DESC_UPDATED",
	"ASC_HEIGHT",
	"DESC_HEIGHT",
	"ASC_WIDTH",
	"DESC_WIDTH",
	"ASC_SIZE",
	"DESC_SIZE",
}
View Source
var VALID_TYPES = []string{"all", "file", "folder"}

Functions

This section is empty.

Types

type Bool

type Bool bool

Represents a typed boolean value.

type FileDetails

type FileDetails struct {
	FileId            *String           `json:"fileId" binding:"-"`
	Type              *String           `json:"type" binding:"-"`
	Name              *String           `json:"name" binding:"-"`
	FilePath          *String           `json:"filePath" binding:"-"`
	Tags              *[]String         `json:"tags" binding:"-"`
	AITags            *[]interface{}    `json:"AITags" binding:"-"`
	IsPrivateFile     *Bool             `json:"isPrivateFile" binding:"-"`
	CustomCoordinates *String           `json:"customCoordinates" binding:"-"`
	Url               *String           `json:"url" binding:"-"`
	Thumbnail         *String           `json:"thumbnail" binding:"-"`
	FileType          *String           `json:"fileType" binding:"-"`
	Mime              *String           `json:"mime" binding:"-"`
	Height            Int32             `json:"height" binding:"-"`
	Width             Int32             `json:"width" binding:"-"`
	Size              Int32             `json:"size" binding:"-"`
	HasAlpha          *Bool             `json:"hasAlpha" binding:"-"`
	CustomMetadata    *interface{}      `json:"customMetadata" binding:"-"`
	EmbeddedMetadata  *interface{}      `json:"embeddedMetadata" binding:"-"`
	CreatedAt         *time.Time        `json:"createdAt" binding:"-" time_format:"YYYY-MM-DDTHH:mm:ss.sssZ"`
	UpdatedAt         *time.Time        `json:"updatedAt" binding:"-" time_format:"YYYY-MM-DDTHH:mm:ss.sssZ"`
	ExtensionStatus   map[string]string `json:"extensionStatus" binding:"-"`
}

Represents details about a file.

type FileOptions

type FileOptions struct {
	UseUniqueFileName       *Bool
	Tags                    *[]String
	Folder                  *String
	IsPrivateFile           *Bool
	CustomCoordinates       *String
	ResponseFields          *[]String
	Extensions              *[]interface{}
	WebhookUrl              *String
	OverwriteFile           *Bool
	OverwriteAITags         *Bool
	OverwriteTags           *Bool
	OverwriteCustomMetadata *Bool
	CustomMetadata          *interface{}
}

Represents options for creating or modifying files.

func (FileOptions) ToDict

func (options FileOptions) ToDict() (fields map[string]string, err error)

Converts options to a map of optionName-optionValue pairs.

func (FileOptions) ToJSON

func (options FileOptions) ToJSON() (jsonStr string, err error)

Converts options to its JSON representation.

type FilesFetchParams

type FilesFetchParams struct {
	Type, Sort, Path, SearchQuery *String
	Tags                          *[]String
	FileType                      *String
	Limit, Skip                   *Int32
}

Represents query parameters for fetching files from imagekit.io.

func (FilesFetchParams) BuildURLQuery

func (params FilesFetchParams) BuildURLQuery() (query string, err error)

Creates a URL query from the FilesFetchParams.

type ImageKit

type ImageKit struct {
	PublicKey, PrivateKey, UrlEndpoint string
}

Represents a struct with routines for managing assets on imagekit.io.

func (*ImageKit) AddTags

func (imgKit *ImageKit) AddTags(fileIds, tags []string) (updatedFileIds []string, err error)

Add tags to an array of files.

func (*ImageKit) CopyFile

func (imgKit *ImageKit) CopyFile(srcFilePath, destFolderPath string) (err error)

Copy a file.

func (*ImageKit) CreateFolder

func (imgKit *ImageKit) CreateFolder(folderName, parentFolderPath string) (err error)

Create a folder.

func (*ImageKit) DeleteFile

func (imgKit *ImageKit) DeleteFile(fileId string) (err error)

Delete a file.

func (*ImageKit) DeleteFiles

func (imgKit *ImageKit) DeleteFiles(fileIds []string) (deletedFileIds []string, err error)

Delete an array of files.

func (*ImageKit) DeleteFolder

func (imgKit *ImageKit) DeleteFolder(folderPath string) (err error)

Delete a folder.

func (*ImageKit) DoRequest

func (imgKit *ImageKit) DoRequest(req *http.Request) (body string, err error)

Runs an http request.

func (*ImageKit) GetFileDetails

func (imgKit *ImageKit) GetFileDetails(fileId string) (fileDetail *FileDetails, err error)

Get details of a file.

func (*ImageKit) GetFiles

func (imgKit *ImageKit) GetFiles(
	params *FilesFetchParams) (fileDetails *[]FileDetails, err error)

List and search files.

func (*ImageKit) MoveFile

func (imgKit *ImageKit) MoveFile(srcFilePath, destFolderPath string) (err error)

Move a file.

func (*ImageKit) RemoveAITags

func (imgKit *ImageKit) RemoveAITags(fileIds, aiTags []string) (updatedFileIds []string, err error)

Remove AI tags from an array of files.

func (*ImageKit) RemoveTags

func (imgKit *ImageKit) RemoveTags(fileIds, tags []string) (updatedFileIds []string, err error)

Remove tags from an array of files.

func (*ImageKit) RenameFile

func (imgKit *ImageKit) RenameFile(srcFilePath, newFileName string, purgeCache ...bool) (purgeRequestId string, err error)

Rename a file.

func (*ImageKit) UpdateFileDetails

func (imgKit *ImageKit) UpdateFileDetails(
	fileId string,
	options *FileOptions) (fileDetail *FileDetails, err error)

Update details of a file.

func (*ImageKit) Upload

func (imgKit *ImageKit) Upload(
	file,
	fileName string,
	options *FileOptions) (result *FileDetails, err error)

Uploads a file to ImageKit.io.

type Int32

type Int32 int32

Represents a typed 32-bit integer value.

type String

type String string

Represents a typed string value.

func (String) StringInArray

func (str String) StringInArray(arr []string) bool

Checks if a string is in an array of strings.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL