Documentation
¶
Overview ¶
Package client provides a client for interacting with the ImageKit API.
Index ¶
- type AITag
- type CreateFolderParam
- type DeleteFolderParam
- type File
- type FilesOrFolderParam
- type Folder
- type ImageKit
- func (ik *ImageKit) BulkJobStatus(ctx context.Context, jobID string) (*http.Response, *JobStatus, error)
- func (ik *ImageKit) CreateFolder(ctx context.Context, param CreateFolderParam) (*http.Response, error)
- func (ik *ImageKit) DeleteFile(ctx context.Context, fileID string) (*http.Response, error)
- func (ik *ImageKit) DeleteFolder(ctx context.Context, param DeleteFolderParam) (*http.Response, error)
- func (ik *ImageKit) File(ctx context.Context, fileID string) (*http.Response, *File, error)
- func (ik *ImageKit) Files(ctx context.Context, params FilesOrFolderParam, includeVersion bool) (*http.Response, *[]File, error)
- func (ik *ImageKit) Folders(ctx context.Context, params FilesOrFolderParam) (*http.Response, *[]Folder, error)
- func (ik *ImageKit) MoveFolder(ctx context.Context, param MoveFolderParam) (*http.Response, *JobIDResponse, error)
- func (ik *ImageKit) URL(params URLParam) (string, error)
- func (ik *ImageKit) Upload(ctx context.Context, file io.Reader, param UploadParam) (*http.Response, *UploadResult, error)
- type JobIDResponse
- type JobStatus
- type MoveFolderParam
- type NewParams
- type URLParam
- type UploadParam
- type UploadResult
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type AITag ¶
type AITag struct {
Name string `json:"name"`
Confidence float32 `json:"confidence"`
Source string `json:"source"`
}
AITag represents an AI tag for a media library file.
type CreateFolderParam ¶
type CreateFolderParam struct {
FolderName string `validate:"nonzero" json:"folderName"`
ParentFolderPath string `validate:"nonzero" json:"parentFolderPath"`
}
CreateFolderParam represents parameter to create folder api
type DeleteFolderParam ¶
type DeleteFolderParam struct {
FolderPath string `validate:"nonzero" json:"folderPath"`
}
DeleteFolderParam represents parameter to delete folder api
type File ¶
type File struct {
FileID string `json:"fileId"`
Name string `json:"name"`
FilePath string `json:"filePath"`
Type string `json:"type"`
VersionInfo map[string]string `json:"versionInfo"`
IsPrivateFile *bool `json:"isPrivateFile"`
CustomCoordinates *string `json:"customCoordinates"`
URL string `json:"url"`
Thumbnail string `json:"thumbnail"`
FileType string `json:"fileType"`
Mime string `json:"mime"`
Height int `json:"height"`
Width int `json:"Width"`
Size uint64 `json:"size"`
HasAlpha bool `json:"hasAlpha"`
CustomMetadata map[string]any `json:"customMetadata,omitempty"`
EmbeddedMetadata map[string]any `json:"embeddedMetadata"`
CreatedAt time.Time `json:"createdAt"`
UpdatedAt time.Time `json:"updatedAt"`
Tags []string `json:"tags"`
AITags []AITag `json:"AITags"`
}
File represents media library File details.
type FilesOrFolderParam ¶
type FilesOrFolderParam struct {
Path string `json:"path,omitempty"`
Limit int `json:"limit,omitempty"`
Skip int `json:"skip,omitempty"`
SearchQuery string `json:"searchQuery,omitempty"`
}
FilesOrFolderParam struct is a parameter type to ListFiles() function to search / list media library files.
type ImageKit ¶
type ImageKit struct {
Prefix string
UploadPrefix string
Timeout int64
UploadTimeout int64
PrivateKey string
PublicKey string
URLEndpoint string
HTTPClient *rest.Client
}
ImageKit main struct
func (*ImageKit) BulkJobStatus ¶
func (ik *ImageKit) BulkJobStatus(ctx context.Context, jobID string) (*http.Response, *JobStatus, error)
BulkJobStatus retrieves the status of a bulk job by job ID.
func (*ImageKit) CreateFolder ¶
func (ik *ImageKit) CreateFolder(ctx context.Context, param CreateFolderParam) (*http.Response, error)
CreateFolder creates a new folder in media library
func (*ImageKit) DeleteFile ¶
DeleteFile removes file by FileID from media library
func (*ImageKit) DeleteFolder ¶
func (ik *ImageKit) DeleteFolder(ctx context.Context, param DeleteFolderParam) (*http.Response, error)
DeleteFolder removes the folder from media library
func (*ImageKit) Files ¶
func (ik *ImageKit) Files(ctx context.Context, params FilesOrFolderParam, includeVersion bool) (*http.Response, *[]File, error)
Files retrieves media library files. Filter options can be supplied as FilesOrFolderParam.
func (*ImageKit) Folders ¶
func (ik *ImageKit) Folders(ctx context.Context, params FilesOrFolderParam) (*http.Response, *[]Folder, error)
Folders retrieves media library files. Filter options can be supplied as FilesOrFolderParam.
func (*ImageKit) MoveFolder ¶
func (ik *ImageKit) MoveFolder(ctx context.Context, param MoveFolderParam) (*http.Response, *JobIDResponse, error)
MoveFolder moves given folder to new path in media library
func (*ImageKit) Upload ¶
func (ik *ImageKit) Upload(ctx context.Context, file io.Reader, param UploadParam) (*http.Response, *UploadResult, error)
Upload uploads an asset to a imagekit account.
The asset can be:
- the actual data (io.Reader)
- the Data URI (Base64 encoded), max ~60 MB (62,910,000 chars)
- the remote FTP, HTTP or HTTPS URL address of an existing file
https://docs.imagekit.io/api-reference/upload-file-api/server-side-file-upload
type JobIDResponse ¶
type JobIDResponse struct {
JobID string `json:"jobId"`
}
JobIDResponse represents response struct with JobID for folder operations
type JobStatus ¶
type JobStatus struct {
JobID string `json:"jobId"`
Type string `json:"type"`
Status string `json:"status"`
}
JobStatus represents response Data to job status api
type MoveFolderParam ¶
type MoveFolderParam struct {
SourceFolderPath string `validate:"nonzero" json:"sourceFolderPath"`
DestinationPath string `validate:"nonzero" json:"destinationPath"`
}
MoveFolderParam represents parameter to move folder api
type URLParam ¶
type URLParam struct {
Path string
Src string
URLEndpoint string
Signed bool
ExpireSeconds int64
QueryParameters map[string]string
}
URLParam represents parameters for generating url
type UploadParam ¶
type UploadParam struct {
FileName string `json:"fileName"`
Folder string `json:"folder,omitempty"` // default value: /
Tags string `json:"tags,omitempty"`
IsPrivateFile *bool `json:"isPrivateFile,omitempty"` // default: false
}
UploadParam defines upload parameters
type UploadResult ¶
type UploadResult struct {
FileID string `json:"fileId"`
Name string `json:"name"`
URL string `json:"url"`
ThumbnailURL string `json:"thumbnailUrl"`
Height int `json:"height"`
Width int `json:"Width"`
Size uint64 `json:"size"`
FilePath string `json:"filePath"`
AITags []map[string]any `json:"AITags"`
VersionInfo map[string]string `json:"versionInfo"`
}
UploadResult defines the response structure for the upload API