Documentation
¶
Overview ¶
Package imagekit provides Go client to work with Imagekit.io image processing service API.
Index ¶
- type Client
- type DeleteFilesRequest
- type DeleteFilesResponse
- type ErrorResponse
- type GetFileDetailsResponse
- type ListAndSearchFileRequest
- type ListAndSearchFileResponse
- type MediaService
- func (s *MediaService) DeleteFile(ctx context.Context, fid string) error
- func (s *MediaService) DeleteFiles(ctx context.Context, r *DeleteFilesRequest) (*DeleteFilesResponse, error)
- func (s *MediaService) GetFileDetails(ctx context.Context, fid string) (*GetFileDetailsResponse, error)
- func (s *MediaService) ListAndSearchFile(ctx context.Context, r *ListAndSearchFileRequest) (*[]ListAndSearchFileResponse, error)
- func (s *MediaService) PurgeCache(ctx context.Context, r *PurgeCacheRequest) (*PurgeCacheResponse, error)
- func (s *MediaService) PurgeCacheStatus(ctx context.Context, rid string) (*PurgeCacheStatusResponse, error)
- func (s *MediaService) UpdateFileDetails(ctx context.Context, fid string, r *UpdateFileDetailsRequest) (*UpdateFileDetailsResponse, error)
- type MetadataEXIF
- type MetadataGPS
- type MetadataImage
- type MetadataInteroperability
- type MetadataMakernote
- type MetadataResponse
- type MetadataResponseEXIF
- type MetadataService
- type MetadataThumbnail
- type Options
- type PurgeCacheRequest
- type PurgeCacheResponse
- type PurgeCacheStatusResponse
- type UpdateFileDetailsRequest
- type UpdateFileDetailsResponse
- type UploadRequest
- type UploadResponse
- type UploadService
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Client ¶
type Client struct {
// Upload API.
Upload *UploadService
// Media API.
Media *MediaService
// Metadata API.
Metadata *MetadataService
// contains filtered or unexported fields
}
Client manages communication with the API.
type DeleteFilesRequest ¶
type DeleteFilesRequest struct {
// FileIDs is the list of unique ID of the uploaded files.
FileIDs []string `json:"fileIds"`
}
type DeleteFilesResponse ¶
type DeleteFilesResponse struct {
// SuccessfullyDeletedFileIDs is the array of fileIds which are successfully deleted.
SuccessfullyDeletedFileIDs []string `json:"successfullyDeletedFileIds"`
}
type ErrorResponse ¶
type ErrorResponse struct {
Response *http.Response
Message string `json:"message"`
Help string `json:"help"`
MissingFileIDs []string `json:"missingFileIds,omitempty"`
}
ErrorResponse reports error caused by an API request.
func (*ErrorResponse) Error ¶
func (r *ErrorResponse) Error() string
Errors provides string error of error repsponse r.
type GetFileDetailsResponse ¶
type GetFileDetailsResponse struct {
// FileID is the unique ID of the uploaded file.
FileID string `json:"fileId"`
// Type of item. It can be either file or imageFolder.
Type string `json:"type"`
// Name of the file or imageFolder.
Name string `json:"name"`
// FilePath of the file. In the case of an image, you can use this path to construct different transform.
FilePath string `json:"filePath"`
// Tags is array of tags associated with the image.
Tags []string `json:"tags"`
// IsPrivateFile is the file marked as private. It can be either "true" or "false".
IsPrivateFile bool `json:"isPrivateFile"`
// CustomCoordinates is the value of custom coordinates associated with the image in format "x,y,width,height".
CustomCoordinates string `json:"customCoordinates"`
// URL of the file.
URL string `json:"url"`
// Thumbnail is a small thumbnail URL in case of an image.
Thumbnail string `json:"thumbnail"`
// FileType of the file, it could be either image or non-image.
FileType string `json:"fileType"`
}
type ListAndSearchFileRequest ¶
type ListAndSearchFileRequest struct {
// Path if you want to limit the search within a specific imageFolder.
//
// For example, /sales-banner/ will only search in imageFolder sales-banner.
Path string
// FileType to include in result set.
//
// Accepts three values:
// all - include all types of files in result set
// image - only search in image type files
// non-image - only search in files which are not image, e.g., JS or CSS or video files.
// Default value - all.
FileType string
// Files matching any of the Tags are included in result response.
//
// If no tag is matched, the file is not included in result set.
Tags []string
// IncludeFolder in search results or not. By default only files are searched.
//
// Accepts true and false. If this is set to true then tags and FileType parameters are ignored.
IncludeFolder bool
// Name of the file or imageFolder.
Name string
// Limit the maximum number of results to return in response.
//
// Minimum value - 1
// Maximum value - 1000
// Default value - 1000
Limit int
// Skip the number of results before returning results.
//
// Minimum value - 0
// Default value - 0
Skip int
}
type ListAndSearchFileResponse ¶
type ListAndSearchFileResponse struct {
// FileID is the unique ID of the uploaded file.
FileID string `json:"fileId"`
// Type of item. It can be either file or imageFolder.
Type string `json:"type"`
// Name of the file or imageFolder.
Name string `json:"name"`
// FilePath of the file. In the case of an image, you can use this path to construct different transform.
FilePath string `json:"filePath"`
// Tags is array of tags associated with the image.
Tags []string `json:"tags"`
// IsPrivateFile is the file marked as private. It can be either "true" or "false".
IsPrivateFile bool `json:"isPrivateFile"`
// CustomCoordinates is the value of custom coordinates associated with the image in format "x,y,width,height".
CustomCoordinates string `json:"customCoordinates"`
// URL of the file.
URL string `json:"url"`
// Thumbnail is a small thumbnail URL in case of an image.
Thumbnail string `json:"thumbnail"`
// FileType of the file, it could be either image or non-image.
FileType string `json:"fileType"`
}
type MediaService ¶
type MediaService service
MediaService handles communication with the media related methods of the Imagekit.io API.
func (*MediaService) DeleteFile ¶
func (s *MediaService) DeleteFile(ctx context.Context, fid string) error
DeleteFile deletes file with id and all its transform.
func (*MediaService) DeleteFiles ¶
func (s *MediaService) DeleteFiles(ctx context.Context, r *DeleteFilesRequest) (*DeleteFilesResponse, error)
DeleteFiles deletes multiple files uploaded in media library using bulk file delete API.
When you delete a file, all its transform are also deleted. However, if a file or specific transformation has been requested in the past, then the response is cached in CDN. You can purge the cache from the CDN using purge API.
func (*MediaService) GetFileDetails ¶
func (s *MediaService) GetFileDetails(ctx context.Context, fid string) (*GetFileDetailsResponse, error)
GetFileDetails such as tags, customCoordinates, and isPrivate properties using get file detail API.
func (*MediaService) ListAndSearchFile ¶
func (s *MediaService) ListAndSearchFile(ctx context.Context, r *ListAndSearchFileRequest) (*[]ListAndSearchFileResponse, error)
ListAndSearchFile lists all the uploaded files in your Imagekit.io media library.
func (*MediaService) PurgeCache ¶
func (s *MediaService) PurgeCache(ctx context.Context, r *PurgeCacheRequest) (*PurgeCacheResponse, error)
PurgeCache will purge CDN and Imagekit.io internal cache.
func (*MediaService) PurgeCacheStatus ¶
func (s *MediaService) PurgeCacheStatus(ctx context.Context, rid string) (*PurgeCacheStatusResponse, error)
PurgeCacheStatus gets the status of submitted purge request.
func (*MediaService) UpdateFileDetails ¶
func (s *MediaService) UpdateFileDetails(ctx context.Context, fid string, r *UpdateFileDetailsRequest) (*UpdateFileDetailsResponse, error)
GetFileDetails such as tags, customCoordinates, and isPrivate properties using get file detail API.
type MetadataEXIF ¶
type MetadataEXIF struct {
ApertureValue float32 `json:"ApertureValue"`
ColorSpace int `json:"ColorSpace"`
CreateDate string `json:"CreateDate"`
CustomRendered int `json:"CustomRendered"`
DateTimeOriginal string `json:"DateTimeOriginal"`
ExifImageHeight int `json:"ExifImageHeight"`
ExifImageWidth int `json:"ExifImageWidth"`
ExifVersion string `json:"ExifVersion"`
ExposureCompensation int `json:"ExposureCompensation"`
ExposureMode int `json:"ExposureMode"`
ExposureProgram int `json:"ExposureProgram"`
ExposureTime float32 `json:"ExposureTime"`
FNumber float32 `json:"FNumber"`
Flash int `json:"Flash"`
FlashpixVersion string `json:"FlashpixVersion"`
FocalLength int `json:"FocalLength"`
FocalPlaneResolutionUnit int `json:"FocalPlaneResolutionUnit"`
FocalPlaneXResolution float32 `json:"FocalPlaneXResolution"`
FocalPlaneYResolution float32 `json:"FocalPlaneYResolution"`
ISO int `json:"ISO"`
InteropOffset int `json:"InteropOffset"`
MeteringMode int `json:"MeteringMode"`
SceneCaptureType int `json:"SceneCaptureType"`
ShutterSpeedValue float32 `json:"ShutterSpeedValue"`
SubSecTime string `json:"SubSecTime"`
SubSecTimeDigitized string `json:"SubSecTimeDigitized"`
SubSecTimeOriginal string `json:"SubSecTimeOriginal"`
WhiteBalance int `json:"WhiteBalance"`
}
type MetadataGPS ¶
type MetadataGPS struct {
GPSVersionID []int `json:"GPSVersionID"`
}
type MetadataImage ¶
type MetadataImage struct {
EXIFOffset int `json:"ExifOffset"`
GPSInfo int `json:"GPSInfo"`
Make string `json:"Make"`
Model string `json:"Model"`
ModifyDate string `json:"ModifyDate"`
Orientation int `json:"Orientation"`
ResolutionUnit int `json:"ResolutionUnit"`
Software string `json:"Software"`
XResolution int `json:"XResolution"`
YCbCrPositioning int `json:"YCbCrPositioning"`
YResolution int `json:"YResolution"`
}
type MetadataMakernote ¶
type MetadataMakernote struct {
}
type MetadataResponse ¶
type MetadataResponse struct {
Density int `json:"density"`
EXIF *MetadataResponseEXIF `json:"exif"`
Format string `json:"format"`
HasColorProfile bool `json:"hasColorProfile"`
HasTransparency bool `json:"hasTransparency"`
Height int `json:"height"`
PHash string `json:"pHash"`
Quality int `json:"quality"`
Size int `json:"size"`
Width int `json:"width"`
}
type MetadataResponseEXIF ¶
type MetadataResponseEXIF struct {
EXIF *MetadataEXIF `json:"exif"`
GPS *MetadataGPS `json:"gps"`
Image *MetadataImage `json:"image"`
Interoperability *MetadataInteroperability `json:"interoperability"`
Makernote *MetadataMakernote `json:"makernote"`
Thumbnail *MetadataThumbnail `json:"thumbnail"`
}
type MetadataService ¶
type MetadataService service
MetadataService handles communication with the metadata related methods of the ImageKit API.
func (*MetadataService) GetForUploaded ¶
func (s *MetadataService) GetForUploaded(ctx context.Context, fid string) (*MetadataResponse, error)
GetForUploaded gets image exif, pHash and other metadata for uploaded files in Imagekit.io media library using this API.
func (*MetadataService) GetFromRemote ¶
func (s *MetadataService) GetFromRemote(ctx context.Context, URL string) (*MetadataResponse, error)
GetFromRemote gets image exif, pHash and other metadata from Imagekit.io powered remote URL using this API.
type MetadataThumbnail ¶
type PurgeCacheRequest ¶
type PurgeCacheRequest struct {
// URL is the exact URL of the file to be purged.
//
// For example - https://ik.imageki.io/your_imagekit_id/rest-of-the-file-path.jpg.
URL string `json:"url"`
}
type PurgeCacheResponse ¶
type PurgeCacheResponse struct {
// RequestID which can be used to get the purge request status.
RequestID string `json:"requestId"`
}
type PurgeCacheStatusResponse ¶
type PurgeCacheStatusResponse struct {
// Status is the current status of a submitted purge request.
//
// It can be either:
// Pending - The request has been successfully submitted, and purging is in progress.
// Complete - The purge request has been successfully completed. And now you should get a fresh object. Check the Age header in response to confirm this.
Status string `json:"status"`
}
type UpdateFileDetailsResponse ¶
type UpdateFileDetailsResponse struct {
// FileID is the unique ID of the uploaded file.
FileID string `json:"fileId"`
// Type of item. It can be either file or imageFolder.
Type string `json:"type"`
// Name of the file or imageFolder.
Name string `json:"name"`
// FilePath of the file. In the case of an image, you can use this path to construct different transform.
FilePath string `json:"filePath"`
// Tags is array of tags associated with the image.
Tags []string `json:"tags"`
// IsPrivateFile is the file marked as private. It can be either "true" or "false".
IsPrivateFile bool `json:"isPrivateFile"`
// CustomCoordinates is the value of custom coordinates associated with the image in format "x,y,width,height".
CustomCoordinates string `json:"customCoordinates"`
// URL of the file.
URL string `json:"url"`
// Thumbnail is a small thumbnail URL in case of an image.
Thumbnail string `json:"thumbnail"`
// FileType of the file, it could be either image or non-image.
FileType string `json:"fileType"`
}
type UploadRequest ¶
type UploadRequest struct {
// File to upload.
File interface{}
// FileName with which the file has to be uploaded.
FileName string
// UseUniqueFileName to whether to use a unique filename for this file or not.
UseUniqueFileName bool
// Tags while uploading the file.
Tags []string
// Folder path (e.g. /images/imageFolder/) in which the image has to be uploaded. If the imageFolder(s) didn't exist before, a new imageFolder(s) is created.
Folder string
// IsPrivateFile to whether to mark the file as private or not. This is only relevant for image type files.
IsPrivateFile bool
// CustomCoordinates define an important area in the image. This is only relevant for image type files.
CustomCoordinates string
// ResponseFields contains values of the fields that you want ImageKit.io to return in response.
ResponseFields []string
}
type UploadResponse ¶
type UploadResponse struct {
// FileID is unique.
//
// Store this fileld in your database, as this will be used to perform update action on this file.
FileID string `json:"fileId"`
// Name of the uploaded file.
Name string `json:"name"`
// URL of the file.
URL string `json:"url"`
// Thumbnail is a small thumbnail URL in case of an image.
Thumbnail string `json:"thumbnail"`
// Height of the uploaded image file.
//
// Only applicable when file type is image.
Height int `json:"height"`
// Width of the uploaded image file.
//
// Only applicable when file type is image.
Width int `json:"width"`
// Size of the uploaded file in bytes.
Size int `json:"size"`
// FileType can either be "image" or "non-image".
FileType string `json:"fileType"`
// FilePath is the path of the file uploaded.
//
// It includes any imageFolder that you specified while uploading.
FilePath string `json:"filePath"`
// Tags is array of tags associated with the image.
Tags []string `json:"tags"`
// IsPrivateFile is the file marked as private.
//
// It can be either "true" or "false".
IsPrivateFile bool `json:"isPrivateFile"`
// CustomCoordinates is the value of custom coordinates associated with the image in format "x,y,width,height".
CustomCoordinates string `json:"customCoordinates"`
// Metadata of the upload file.
//
// Use responseFields property in request to get the metadata returned in response of upload API.
Metadata interface{} `json:"metadata"`
}
type UploadService ¶
type UploadService service
UploadService handles communication with the upload related methods of the ImageKit API.
func (*UploadService) ServerUpload ¶
func (s *UploadService) ServerUpload(ctx context.Context, r *UploadRequest) (*UploadResponse, error)
ServerUpload uploads file to ImageKit.io.