Documentation ¶
Index ¶
- func CheckResponse(r *http.Response) error
- type AdminResponse
- type AdminService
- func (as *AdminService) DeleteAllResources(opts ...SetOpts) (ar *AdminResponse, resp *Response, err error)
- func (as *AdminService) DeleteDerivedResources(derivedResourceIds string, opts ...SetOpts) (ar *AdminResponse, resp *Response, err error)
- func (as *AdminService) DeleteDerivedResourcesByTransformation(publicId, transformation []string, opts ...SetOpts) (ar *AdminResponse, resp *Response, err error)
- func (as *AdminService) DeleteResources(ctx context.Context, publicIds []string, opts ...SetOpts) (ar *AdminResponse, resp *Response, err error)
- func (as *AdminService) DeleteResourcesByPrefix(ctx context.Context, prefix string, opts ...SetOpts) (ar *AdminResponse, resp *Response, err error)
- func (as *AdminService) DeleteResourcesByTag(ctx context.Context, tag string, opts ...SetOpts) (ar *AdminResponse, resp *Response, err error)
- type Client
- func (c *Client) Do(ctx context.Context, req *http.Request, v interface{}) (*Response, error)
- func (c *Client) NewRequest(method, urlStr string, body interface{}) (*http.Request, error)
- func (c *Client) NewUploadRequest(urlStr string, reader io.Reader, writer *multipart.Writer) (*http.Request, error)
- type ErrorResponse
- type Options
- func (o *Options) GetInvalidate() bool
- func (o *Options) GetKeepOriginal() bool
- func (o *Options) GetNextCursor() string
- func (o *Options) GetPublicId() string
- func (o *Options) GetResourceType() string
- func (o *Options) GetTimestamp() string
- func (o *Options) GetType() string
- func (o *Options) GetUploadPreset() string
- type ResourceType
- type Response
- type SetOpts
- func WithAccessMode(accessMode string) SetOpts
- func WithAutoTagging(autoTagging float64) SetOpts
- func WithCategorization(c string) SetOpts
- func WithColors(hasColor bool) SetOpts
- func WithContext(ctx string) SetOpts
- func WithDetection(d string) SetOpts
- func WithDiscardOriginalFilename(dof bool) SetOpts
- func WithExif(e bool) SetOpts
- func WithFaces(returnFaces bool) SetOpts
- func WithFolder(folder string) SetOpts
- func WithImageMetadata(returnImageMetadata bool) SetOpts
- func WithKeepOriginal(ko bool) SetOpts
- func WithOCR(ocr string) SetOpts
- func WithOverwrite(isOverwrite bool) SetOpts
- func WithPhash(returnPhash bool) SetOpts
- func WithPublicId(id string) SetOpts
- func WithQualityAnalysis(returnQualityAnalysis bool) SetOpts
- func WithResourceType(resourceType string) SetOpts
- func WithTags(tags string) SetOpts
- func WithType(typeStr string) SetOpts
- func WithUniqueFilename(isUniqueFilename bool) SetOpts
- func WithUploadPreset(uploadPreset string) SetOpts
- func WithUseFilename(isUseFilename bool) SetOpts
- type UploadRequest
- type UploadResponse
- type UploadService
- func (us *UploadService) UnsignedUploadImage(ctx context.Context, filePath string, uploadPreset string, opts ...SetOpts) (ur *UploadResponse, r *Response, err error)
- func (us *UploadService) UploadImage(ctx context.Context, filePath string, opts ...SetOpts) (ur *UploadResponse, r *Response, err error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CheckResponse ¶
CheckResponse checks the API response for errors, and returns them if present. A response is considered an error if it has a status code outside the 200 range or equal to 202 Accepted. API error responses are expected to have either no response body, or a JSON response body that maps to ErrorResponse. Any other response body will be silently ignored.
Types ¶
type AdminResponse ¶
type AdminResponse struct { Deleted interface{} `json:"deleted"` Partial bool `json:"partial"` }
func (*AdminResponse) ToJSON ¶
func (ar *AdminResponse) ToJSON() string
type AdminService ¶
type AdminService service
func (*AdminService) DeleteAllResources ¶
func (as *AdminService) DeleteAllResources(opts ...SetOpts) (ar *AdminResponse, resp *Response, err error)
func (*AdminService) DeleteDerivedResources ¶
func (as *AdminService) DeleteDerivedResources(derivedResourceIds string, opts ...SetOpts) (ar *AdminResponse, resp *Response, err error)
func (*AdminService) DeleteDerivedResourcesByTransformation ¶
func (as *AdminService) DeleteDerivedResourcesByTransformation(publicId, transformation []string, opts ...SetOpts) (ar *AdminResponse, resp *Response, err error)
func (*AdminService) DeleteResources ¶
func (as *AdminService) DeleteResources(ctx context.Context, publicIds []string, opts ...SetOpts) (ar *AdminResponse, resp *Response, err error)
DeleteResource deletes all resources with the given publicIds publicIds is a array that store up to 100 ids
Documentation: https://cloudinary.com/documentation/admin_api#delete_all_or_selected_resources
func (*AdminService) DeleteResourcesByPrefix ¶
func (as *AdminService) DeleteResourcesByPrefix(ctx context.Context, prefix string, opts ...SetOpts) (ar *AdminResponse, resp *Response, err error)
DeleteResource deletes all resources, including derived resources, where the publicId starts with the given prefix (up to maximum of 1000 original resources)
func (*AdminService) DeleteResourcesByTag ¶
func (as *AdminService) DeleteResourcesByTag(ctx context.Context, tag string, opts ...SetOpts) (ar *AdminResponse, resp *Response, err error)
DeleteResourcesByTag deletes all resources and their derivatives with the given tag name, up to a maximum of 1000 original resources
type Client ¶
type Client struct { // BaseURL for the API request. It should always be specified with a trailing slash BaseURL *url.URL // Services used for talking to different parts of the Cloudinary API Upload *UploadService Admin *AdminService // contains filtered or unexported fields }
A Client manages communication with the Cloudinary API
func NewClient ¶
The uri parameter must be a valid URI with the cloudinary:// scheme, e.g. cloudinary://api_key:api_secret@cloud_name
func (*Client) Do ¶
Do sends an API request and returns the API response. The API response is JSON decoded and stored in the value pointed to by v, or returned as an error if an API error has occurred.
The provided ctx must be non-nil. If it is canceled or times out, ctx.Err() will be returned.
func (*Client) NewRequest ¶
NewRequest create an API request. A relative URL can be provided in urlStr, in which case it is resolved relative to the BaseURL of the Client. Relative URLs should always be specified without a preceding slash. If specified, the value pointed to by body is JSON encoded and included as the request body.
type ErrorResponse ¶
type ErrorResponse struct { // HTTP response that caused this error Response *http.Response ErrorData struct { Message string `json:"message"` } `json:"error"` // Errors can also include a documentation_url field // pointing to some content that might help you resolve the error DocumentationURL string `json:"documentation_url,omitempty"` }
func (*ErrorResponse) Error ¶
func (r *ErrorResponse) Error() string
type Options ¶
type Options struct { //AccessControl interface{} `json:"access_control,omitempty"` AccessMode *string `json:"access_mode,omitempty"` AllowedFormats *string `json:"allowed_formats,omitempty"` Async *bool `json:"async,omitempty"` AutoTagging *float64 `json:"auto_tagging,omitempty"` BackgroundRemoval *string `json:"background_removal,omitempty"` Backup *bool `json:"backup,omitempty"` Callback *string `json:"callback,omitempty"` Categorization *string `json:"categorization,omitempty"` Colors *bool `json:"colors,omitempty"` Context *string `json:"context,omitempty"` CustomCoordinates *string `json:"custom_coordinates,omitempty"` Detection *string `json:"detection,omitempty"` DiscardOriginalFilename *bool `json:"discard_original_filename,omitempty"` Eager *string `json:"eager,omitempty"` EagerAsync *bool `json:"eager_async,omitempty"` EagerNotificationURL *string `json:"eager_notification_url,omitempty"` Exif *bool `json:"exif,omitempty"` FaceCoordinates *string `json:"face_coordinates,omitempty"` Faces *bool `json:"faces,omitempty"` Folder *string `json:"folder,omitempty"` Format *string `json:"format,omitempty"` Headers *string `json:"headers,omitempty"` ImageMetadata *bool `json:"image_metadata,omitempty"` Invalidate *bool `json:"invalidate,omitempty"` KeepOriginal *bool `json:"keep_original,omitempty"` Moderation *string `json:"moderation,omitempty"` NextCursor *string `json:"next_cursor,omitempty"` NotificationURL *string `json:"notification_url,omitempty"` OCR *string `json:"ocr,omitempty"` Overwrite *bool `json:"overwrite,omitempty"` Phash *bool `json:"phash,omitempty"` Proxy *string `json:"proxy,omitempty"` PublicId *string `json:"public_id,omitempty"` QualityAnalysis *bool `json:"quality_analysis,omitempty"` RawConvert *string `json:"raw_convert,omitempty"` ReturnDeleteToken *bool `json:"return_delete_token,omitempty"` ResourceType *string `json:"resource_type,omitempty"` Tags *string `json:"tags,omitempty"` Timestamp *string `json:"timestamp,omitempty"` Transformations *string `json:"transformation,omitempty"` Type *string `json:"type,omitempty"` UniqueFilename *bool `json:"unique_filename,omitempty"` // Upload Preset is required for unsigned uploading and // optional for signed uploading UploadPreset *string `json:"upload_preset,omitempty"` UseFilename *bool `json:"use_filename,omitempty"` // contains filtered or unexported fields }
func (*Options) GetInvalidate ¶
func (*Options) GetKeepOriginal ¶
func (*Options) GetNextCursor ¶
func (*Options) GetPublicId ¶
func (*Options) GetResourceType ¶
func (*Options) GetTimestamp ¶
func (*Options) GetUploadPreset ¶
type ResourceType ¶
type ResourceType string
type SetOpts ¶
type SetOpts func(opts *Options)
func WithAccessMode ¶
func WithAutoTagging ¶
func WithCategorization ¶
func WithColors ¶
func WithContext ¶
func WithDetection ¶
func WithFolder ¶
func WithImageMetadata ¶
func WithKeepOriginal ¶
func WithOverwrite ¶
func WithPublicId ¶
func WithQualityAnalysis ¶
func WithResourceType ¶
func WithUniqueFilename ¶
func WithUploadPreset ¶
func WithUseFilename ¶
type UploadRequest ¶
type UploadRequest struct { // Required fields to call upload request File string `json:"file"` }
type UploadResponse ¶
type UploadResponse struct { PublicId string `json:"public_id"` Version int64 `json:"version"` Signature string `json:"signature"` Width int64 `json:"width"` Height int64 `json:"height"` Format string `json:"format"` ResourceType string `json:"resource_type"` CreatedAt string `json:"created_at"` Tags []string `json:"tags"` Bytes int64 `json:"bytes"` Type string `json:"type"` Etag string `json:"etag"` Placeholder bool `json:"placeholder"` URL string `json:"url"` SecureURL string `json:"secure_url"` AccessMode string `json:"access_mode"` OriginalFilename string `json:"original_filename"` Colors [][]interface{} `json:"colors"` }
type UploadService ¶
type UploadService service
func (*UploadService) UnsignedUploadImage ¶
func (us *UploadService) UnsignedUploadImage(ctx context.Context, filePath string, uploadPreset string, opts ...SetOpts) (ur *UploadResponse, r *Response, err error)
UnsignedUploadImage handle unsigned uploading image to Cloudinary. Unsigned request are restricted to the following allowed parameters: `public_id`, `folder`, `callback`, `tags`, `context`, `face_coordinates` (image-only), `custom_coordinates` (image-only) and `upload_preset`. Most of the other upload parameters can be defined in your `upload_preset`.
Additionally, although the `public_id` parameter can be specified, the `overwrite` parameter is always set to `false` for unsigned uploads to prevent overwriting existing file.
func (*UploadService) UploadImage ¶
func (us *UploadService) UploadImage(ctx context.Context, filePath string, opts ...SetOpts) (ur *UploadResponse, r *Response, err error)
UploadImage handle signed uploading image to Cloudinary Signed request are required `signature` parameters