Documentation
¶
Overview ¶
Package imagekit provides Go client to work with Imagekit.io image processing service API.
Index ¶
- type AddTagsRequest
- type BulkJobStatusResponse
- type Client
- type CopyFileRequest
- type CopyFolderRequest
- type CopyFolderResponse
- type CreateFolderRequest
- type DeleteFilesRequest
- type DeleteFilesResponse
- type DeleteFolderRequest
- type ErrorResponse
- type GetFileDetailsResponse
- type ListAndSearchFileRequest
- type ListAndSearchFileResponse
- type MediaService
- func (s *MediaService) AddTags(ctx context.Context, r *AddTagsRequest) error
- func (s *MediaService) BulkJobStatus(ctx context.Context, jid string) (*BulkJobStatusResponse, error)
- func (s *MediaService) CopyFile(ctx context.Context, r *CopyFileRequest) error
- func (s *MediaService) CopyFolder(ctx context.Context, r *CopyFolderRequest) (*CopyFolderResponse, error)
- func (s *MediaService) CreateFolder(ctx context.Context, r *CreateFolderRequest) error
- func (s *MediaService) DeleteFile(ctx context.Context, fid string) error
- func (s *MediaService) DeleteFiles(ctx context.Context, r *DeleteFilesRequest) (*DeleteFilesResponse, error)
- func (s *MediaService) DeleteFolder(ctx context.Context, r *DeleteFolderRequest) 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) MoveFile(ctx context.Context, r *MoveFileRequest) error
- func (s *MediaService) MoveFolder(ctx context.Context, r *MoveFolderRequest) (*MoveFolderResponse, 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) RemoveTags(ctx context.Context, r *RemoveTagsRequest) 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 MoveFileRequest
- type MoveFolderRequest
- type MoveFolderResponse
- type Options
- type PurgeCacheRequest
- type PurgeCacheResponse
- type PurgeCacheStatusResponse
- type RemoveTagsRequest
- 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 AddTagsRequest ¶ added in v1.1.0
type BulkJobStatusResponse ¶ added in v1.1.0
type BulkJobStatusResponse struct {
// JobID you get in the response of bulk job API e.g. copy folder or move folder API.
JobID string `json:"jobId"`
// Type of operation, it could be either COPY_FOLDER or MOVE_FOLDER.
Type string `json:"type"`
// Status of the job.
//
// It can be either:
// Pending - The job has been successfully submitted and is in progress.
// Completed - The job has been completed.
Status string `json:"status"`
}
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 CopyFileRequest ¶ added in v1.1.0
type CopyFileRequest struct {
// SourceFilePath is the full path of the file you want to copy.
//
// For example - /path/to/file.jpg
SourceFilePath string `json:"sourceFilePath"`
// DestinationPath is the full path to the folder you want to copy the above file into.
//
// For example - /folder/to/copy/into/
DestinationPath string `json:"destinationPath"`
}
type CopyFolderRequest ¶ added in v1.1.0
type CopyFolderRequest struct {
// SourceFolderPath is the full path to the source folder you want to copy.
//
// For example - /path/of/source/folder
SourceFolderPath string `json:"sourceFolderPath"`
// DestinationPath is the full path to the destination folder where you want to copy the source folder into.
//
// For example - /path/of/destination/folder/
DestinationPath string `json:"destinationPath"`
}
type CopyFolderResponse ¶ added in v1.1.0
type CopyFolderResponse struct {
JobID string `json:"jobId"`
}
type CreateFolderRequest ¶ added in v1.1.0
type CreateFolderRequest struct {
// FolderName of the folder to create.
//
// All characters except alphabets and numbers will be replaced by an underscore i.e. _
FolderName string `json:"folderName"`
// ParentFolderPath where the new folder should be created.
//
// For root use / else containing/folder/
// Note: If any folder(s) is not present in the parentFolderPath parameter, it will be automatically created. For example,
// if you pass /product/images/summer, then product, images, and summer folders will be created if they don't already exist.
ParentFolderPath string `json:"parentFolderPath"`
}
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 DeleteFolderRequest ¶ added in v1.1.0
type DeleteFolderRequest struct {
// FolderPath is a full path to the folder you want to delete.
//
// For example folder/to/delete/
FolderPath string `json:"folderPath"`
}
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"`
// MIME Type of the file.
MIME string `json:"mime"`
// 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"`
// HasAlpha is whether the image has an alpha component or not.
HasAlpha bool `json:"hasAlpha"`
// The date and time when the file was first uploaded.
//
// The format is YYYY-MM-DDTHH:mm:ss.sssZ
CreatedAt time.Time `json:"created_at"`
}
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"`
// MIME Type of the file.
MIME string `json:"mime"`
// 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"`
// HasAlpha is whether the image has an alpha component or not.
HasAlpha bool `json:"hasAlpha"`
// The date and time when the file was first uploaded.
//
// The format is YYYY-MM-DDTHH:mm:ss.sssZ
CreatedAt time.Time `json:"created_at"`
}
type MediaService ¶
type MediaService service
MediaService handles communication with the media related methods of the Imagekit.io API.
func (*MediaService) AddTags ¶ added in v1.1.0
func (s *MediaService) AddTags(ctx context.Context, r *AddTagsRequest) error
AddTags to multiple files in a single request.
func (*MediaService) BulkJobStatus ¶ added in v1.1.0
func (s *MediaService) BulkJobStatus(ctx context.Context, jid string) (*BulkJobStatusResponse, error)
BulkJobStatus will copy one folder into another.
func (*MediaService) CopyFile ¶ added in v1.1.0
func (s *MediaService) CopyFile(ctx context.Context, r *CopyFileRequest) error
CopyFile will copy a file from one folder to another.
func (*MediaService) CopyFolder ¶ added in v1.1.0
func (s *MediaService) CopyFolder(ctx context.Context, r *CopyFolderRequest) (*CopyFolderResponse, error)
CopyFolder will copy one folder into another.
func (*MediaService) CreateFolder ¶ added in v1.1.0
func (s *MediaService) CreateFolder(ctx context.Context, r *CreateFolderRequest) error
CreateFolder will create a new folder.
You can specify the folder name and location of the parent folder where this new folder should be created.
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) DeleteFolder ¶ added in v1.1.0
func (s *MediaService) DeleteFolder(ctx context.Context, r *DeleteFolderRequest) error
DeleteFolder will delete the specified folder and all nested files & folders.
This action is cannot be undone.
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) MoveFile ¶ added in v1.1.0
func (s *MediaService) MoveFile(ctx context.Context, r *MoveFileRequest) error
MoveFile will move a file from one folder to another.
func (*MediaService) MoveFolder ¶ added in v1.1.0
func (s *MediaService) MoveFolder(ctx context.Context, r *MoveFolderRequest) (*MoveFolderResponse, error)
MoveFolder will move one folder into another.
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) RemoveTags ¶ added in v1.1.0
func (s *MediaService) RemoveTags(ctx context.Context, r *RemoveTagsRequest) error
RemoveTags from multiple files in a single request.
func (*MediaService) UpdateFileDetails ¶
func (s *MediaService) UpdateFileDetails(ctx context.Context, fid string, r *UpdateFileDetailsRequest) (*UpdateFileDetailsResponse, error)
UpdateFileDetails 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 MoveFileRequest ¶ added in v1.1.0
type MoveFileRequest struct {
// SourceFilePath is the full path of the file you want to copy.
//
// For example - /path/to/file.jpg
SourceFilePath string `json:"sourceFilePath"`
// DestinationPath is the full path to the folder you want to copy the above file into.
//
// For example - /folder/to/copy/into/
DestinationPath string `json:"destinationPath"`
}
type MoveFolderRequest ¶ added in v1.1.0
type MoveFolderRequest struct {
// SourceFolderPath is the full path to the source folder you want to move.
//
// For example - /path/of/source/folder
SourceFolderPath string `json:"sourceFolderPath"`
// DestinationPath is the full path to the destination folder where you want to move the source folder into.
//
// For example - /path/of/destination/folder/
DestinationPath string `json:"destinationPath"`
}
type MoveFolderResponse ¶ added in v1.1.0
type MoveFolderResponse struct {
JobID string `json:"jobId"`
}
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 RemoveTagsRequest ¶ added in v1.1.0
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"`
// MIME Type of the file.
MIME string `json:"mime"`
// 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"`
// HasAlpha is whether the image has an alpha component or not.
HasAlpha bool `json:"hasAlpha"`
// The date and time when the file was first uploaded.
//
// The format is YYYY-MM-DDTHH:mm:ss.sssZ
CreatedAt time.Time `json:"created_at"`
}
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"`
// ThumbnailURL is a small thumbnail URL in case of an image.
ThumbnailURL string `json:"thumbnailUrl"`
// 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.
Source Files
¶
- imagekit.go
- media.go
- media_add_tags.go
- media_bulk_job_status.go
- media_copy_file.go
- media_copy_folder.go
- media_create_folder.go
- media_delete_file.go
- media_delete_files.go
- media_delete_folder.go
- media_get_file_details.go
- media_list_and_search_file.go
- media_move_file.go
- media_move_folder.go
- media_purge_cache.go
- media_purge_cache_status.go
- media_remove_tags.go
- media_update_file_details.go
- metadata.go
- metadata_get_for_uploaded.go
- metadata_get_from_remote.go
- upload.go
- upload_server_upload.go