Documentation
¶
Overview ¶
Package api contains packages used for accessing Cloudinary API functionality.
Index ¶
- Constants
- Variables
- func BaseURL(uploadPrefix string, apiVer string) string
- func Bool(b bool) *bool
- func BuildPath(parts ...interface{}) string
- func DeferredClose(c io.Closer)
- func GetUserAgent() string
- func HandleRawResponse(bodyBytes []byte, result interface{}) error
- func IsBase64Data(base64Candidate string) bool
- func IsLocalFilePath(path interface{}) bool
- func IsValidURL(urlCandidate string) bool
- func MarshalJSONRaw(t interface{}) ([]byte, error)
- func ReMarshalJSON(bytes []byte) ([]byte, error)
- func SignParameters(params url.Values, secret string) (string, error)
- func SignParametersUsingAlgo(params url.Values, secret string, algo signature.Algo) (string, error)
- func StructToParams(inputStruct interface{}) (url.Values, error)
- func TimePtr(t time.Time) *time.Time
- type AccessControl
- type AccessControlRule
- type AccessType
- type AssetType
- type BriefAssetResult
- type CldAPIArray
- type CldAPIMap
- type Coordinates
- type DeliveryType
- type EndPoint
- type ErrorResp
- type HookExecution
- type LastUpdated
- type Metadata
- type ModerationStatus
- type Option
Constants ¶
const ( // Image is the image asset type. Image AssetType = "image" // Video is the video asset type. Video = "video" // File is the raw asset type. File = "raw" // Auto is the auto asset type. Tells Cloudinary to automatically detect the type of the uploaded asset. Auto = "auto" // All is the all asset type. Used for downloading folders with all assets inside. All = "all" )
const ( // Upload is the upload delivery type. Upload DeliveryType = "upload" // Private is the private delivery type. Private = "private" // Public is the delivery type. Public = "public" // Authenticated is the delivery type. Authenticated = "authenticated" // Fetch is the fetch delivery type. Fetch = "fetch" // Sprite is the sprite delivery type. Sprite = "sprite" // Text is the text delivery type. Text = "text" // Multi is the multi delivery type. Multi = "multi" // Facebook is the facebook delivery type. Facebook = "facebook" // Twitter is the twitter delivery type. Twitter = "twitter" // TwitterName is the twitter name delivery type. TwitterName = "twitter_name" // Gravatar is the gravatar delivery type. Gravatar = "gravatar" // Youtube is the youtube delivery type. Youtube = "youtube" // Hulu is the hulu delivery type. Hulu = "hulu" // Vimeo is the vimeo delivery type. Vimeo = "vimeo" // Animoto is the animoto delivery type. Animoto = "animoto" // Worldstarhiphop is the world star hip hop delivery type. Worldstarhiphop = "worldstarhiphop" // Dailymotion is the daily motion delivery type. Dailymotion = "dailymotion" )
const ( // Pending is the pending moderation status. Pending ModerationStatus = "pending" // Approved is the approved moderation status. Approved = "approved" // Rejected is the rejected moderation status. Rejected = "rejected" )
const Version = "2.9.1"
Version is the Cloudinary Go package version.
Variables ¶
var UserAgent = fmt.Sprintf("CloudinaryGo/%s (Go %s)", Version, strings.TrimPrefix(runtime.Version(), "go"))
UserAgent contains information about the SDK user agent. Passed to the Cloudinary servers.
var UserPlatform = ""
UserPlatform provides additional information to be passed with the UserAgent, e.g. "CloudinaryIntegration/1.2.3".
This value is set in platform-specific implementations that use cloudinary-go.
The format of the value should be <ProductName>/Version[ (comment)]. http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.43
**Do not set this value in application code!**
Functions ¶
func BuildPath ¶
func BuildPath(parts ...interface{}) string
BuildPath builds (joins) the URL path from the provided parts.
func DeferredClose ¶
DeferredClose is a wrapper around io.Closer.Close method. Logs error if occurred.
func GetUserAgent ¶
func GetUserAgent() string
GetUserAgent provides the UserAgent string that is passed to the Cloudinary servers.
Prepends UserPlatform if it is defined.
func HandleRawResponse ¶ added in v2.4.0
HandleRawResponse sets a raw Response field value (JSON) in the Result structs that support it, for future proofing
func IsBase64Data ¶
IsBase64Data checks whether base64Candidate represents a valid base64 encoded string.
func IsLocalFilePath ¶
func IsLocalFilePath(path interface{}) bool
IsLocalFilePath determines whether the provided path can be a local file.
Since a unix file path can include almost any characters, the way to distinguish between file path and non-file path is to check if it can be URL or Base64 encoded data.
func IsValidURL ¶
IsValidURL checks whether urlCandidate string is a valid URL.
func MarshalJSONRaw ¶ added in v2.3.0
MarshalJSONRaw marshals JSON without HTML characters escaping, which is enabled in the standard library. In addition, it removes the last newline character from the resulting bytes since there is no reason to keep it.
func ReMarshalJSON ¶ added in v2.3.0
ReMarshalJSON unmarshals and then marshals data - as the result the data is sorted by key.
func SignParameters ¶
SignParameters signs parameters using the provided secret.
func SignParametersUsingAlgo ¶ added in v2.6.0
SignParametersUsingAlgo signs parameters using the provided secret and sign algorithm.
func StructToParams ¶
StructToParams serializes struct to url.Values, which can be further sent to the http client.
Types ¶
type AccessControl ¶ added in v2.8.0
type AccessControl []AccessControlRule
AccessControl represents access control params.
func (AccessControl) MarshalJSON ¶ added in v2.8.0
func (acParams AccessControl) MarshalJSON() ([]byte, error)
MarshalJSON writes a quoted string in the custom format.
type AccessControlRule ¶ added in v2.8.0
type AccessControlRule struct { // AccessType sets the access type for the asset. AccessType AccessType `json:"access_type"` // Start defines when the asset starts to be publicly available. Start *time.Time `json:"start,omitempty"` // End defines when the asset ends to be publicly available. End *time.Time `json:"end,omitempty"` }
AccessControlRule stores parameters for the asset access management.
type AccessType ¶ added in v2.8.0
type AccessType string
AccessType represents the access type for the asset.
const ( // Anonymous allows public access to the asset. The anonymous access type can optionally include start and/or end // dates (in ISO 8601 format) that define when the asset is publicly available. Anonymous AccessType = "anonymous" // Token requires either token-based authentication or cookie-based authentication for accessing the asset. Token AccessType = "token" )
type BriefAssetResult ¶
type BriefAssetResult struct { AssetID string `json:"asset_id"` PublicID string `json:"public_id"` AssetFolder string `json:"asset_folder"` DisplayName string `json:"display_name"` Format string `json:"format"` Version int `json:"version"` AssetType string `json:"resource_type"` Type string `json:"type"` CreatedAt time.Time `json:"created_at"` Bytes int `json:"bytes"` Width int `json:"width"` Height int `json:"height"` Backup bool `json:"backup"` AccessMode string `json:"access_mode"` URL string `json:"url"` SecureURL string `json:"secure_url"` Tags []string `json:"tags,omitempty"` Context Metadata `json:"context,omitempty"` Metadata Metadata `json:"metadata,omitempty"` Placeholder bool `json:"placeholder,omitempty"` Error string `json:"error,omitempty"` }
BriefAssetResult represents a partial asset result that is returned when assets are listed.
type CldAPIArray ¶
type CldAPIArray []string
CldAPIArray is not just an alias, in addition it has a custom MarshalJSON() for serialisation purposes.
func (CldAPIArray) MarshalJSON ¶
func (cldAPIArr CldAPIArray) MarshalJSON() ([]byte, error)
MarshalJSON writes a quoted string in the custom format.
type CldAPIMap ¶
CldAPIMap is not just an alias, in addition it has a custom MarshalJSON() for serialisation purposes.
func (CldAPIMap) MarshalJSON ¶
MarshalJSON writes a quoted string in the custom format.
type DeliveryType ¶
type DeliveryType string
DeliveryType is the delivery type of the asset.
func (DeliveryType) String ¶
func (d DeliveryType) String() string
String serializes DeliveryType to string.
type ErrorResp ¶
type ErrorResp struct {
Message string `json:"message"`
}
ErrorResp is the failed api request main struct.
type HookExecution ¶ added in v2.5.0
type HookExecution map[string]interface{}
HookExecution is the result of a hook execution.
type LastUpdated ¶ added in v2.3.0
type LastUpdated struct { AccessControlUpdatedAt time.Time `json:"access_control_updated_at,omitempty"` ContextUpdatedAt time.Time `json:"context_updated_at,omitempty"` MetadataUpdatedAt time.Time `json:"metadata_updated_at,omitempty"` PublicIDUpdatedAt time.Time `json:"public_id_updated_at,omitempty"` TagsUpdatedAt time.Time `json:"tags_updated_at,omitempty"` UpdatedAt time.Time `json:"updated_at,omitempty"` }
LastUpdated represents the details of the asset last updated time.
type Metadata ¶
type Metadata map[string]interface{}
Metadata is the Cloudinary structured metadata.
func (Metadata) MarshalJSON ¶
MarshalJSON writes a quoted string in the custom format.
type ModerationStatus ¶
type ModerationStatus string
ModerationStatus is the moderation status of the asset.
Directories
¶
Path | Synopsis |
---|---|
Package admin is used for accessing Cloudinary Admin API functionality.
|
Package admin is used for accessing Cloudinary Admin API functionality. |
metadata
Package metadata defines the structured metadata.
|
Package metadata defines the structured metadata. |
Package uploader is used for accessing Cloudinary Upload API functionality.
|
Package uploader is used for accessing Cloudinary Upload API functionality. |