config

package
v2.7.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 8, 2024 License: MIT Imports: 6 Imported by: 0

Documentation

Overview

Package config defines the Cloudinary configuration.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type API

type API struct {
	UploadPrefix  string `schema:"upload_prefix" default:"https://api.cloudinary.com"`
	Timeout       int64  `schema:"timeout" default:"60"` // seconds
	UploadTimeout int64  `schema:"upload_timeout"`
	ChunkSize     int64  `schema:"chunk_size" default:"20000000"` // bytes
}

API defines the configuration for making requests to the Cloudinary API.

type AuthToken

type AuthToken struct {
	Key        string `schema:"key"`
	IP         string `schema:"ip"`
	ACL        string `schema:"acl"`
	StartTime  int64  `schema:"start_time"`
	Expiration int64  `schema:"expiration"`
	Duration   int64  `schema:"duration"`
}

AuthToken defines the configuration for delivering token-based authenticated media assets.

https://cloudinary.com/documentation/control_access_to_media#delivering_token_based_authenticated_media_assets

type Cloud

type Cloud struct {
	CloudName          string `schema:"-"`
	APIKey             string `schema:"-"`
	APISecret          string `schema:"-"`
	OAuthToken         string `schema:"oauth_token"`
	SignatureAlgorithm string `schema:"signature_algorithm"`
}

Cloud defines the cloud configuration required to connect your application to Cloudinary.

https://cloudinary.com/documentation/how_to_integrate_cloudinary#get_familiar_with_the_cloudinary_console

func (Cloud) GetSignatureAlgorithm

func (c Cloud) GetSignatureAlgorithm() string

GetSignatureAlgorithm returns the signature algorithm.

type Configuration

type Configuration struct {
	Cloud     Cloud
	API       API
	URL       URL
	AuthToken AuthToken
}

Configuration is the main configuration struct.

func New

func New() (*Configuration, error)

New returns a new Configuration instance from the environment variable

func NewFromOAuthToken

func NewFromOAuthToken(cloud string, oAuthToken string) (*Configuration, error)

NewFromOAuthToken returns a new Configuration instance from the provided cloud name and OAuth token.

func NewFromParams

func NewFromParams(cloud string, key string, secret string) (*Configuration, error)

NewFromParams returns a new Configuration instance from the provided parameters.

func NewFromQueryParams

func NewFromQueryParams(cloud string, key string, secret string, params map[string][]string) (*Configuration, error)

NewFromQueryParams returns a new Configuration instance from the provided url query parameters.

func NewFromURL

func NewFromURL(cldURLStr string) (*Configuration, error)

NewFromURL returns a new Configuration instance from a cloudinary url.

type URL

type URL struct {
	Domain             string `schema:"-" default:"cloudinary.com"`
	SubDomain          string `schema:"-" default:"res"`
	SharedHost         string `schema:"-" default:"res.cloudinary.com"`
	CName              string `schema:"cname"`
	SecureCName        string `schema:"secure_cname"`
	Secure             bool   `schema:"secure" default:"true"`
	CDNSubDomain       bool   `schema:"cdn_sub_domain"`
	SecureCDNSubDomain bool   `schema:"secure_cdn_sub_domain"`
	PrivateCDN         bool   `schema:"private_cdn"`
	SignURL            bool   `schema:"sign_url"`
	LongURLSignature   bool   `schema:"long_url_signature"`
	Shorten            bool   `schema:"shorten"`
	UseRootPath        bool   `schema:"use_root_path"`
	ForceVersion       bool   `schema:"force_version" default:"true"`
	Analytics          bool   `schema:"analytics" default:"true"`
}

URL defines the configuration applied when generating Cloudinary URLs.

https://cloudinary.com/documentation/how_to_integrate_cloudinary#get_familiar_with_the_cloudinary_console

func (URL) GetSignatureLength

func (uc URL) GetSignatureLength() uint8

GetSignatureLength returns the length of the URL signature.

func (URL) Protocol

func (uc URL) Protocol() string

Protocol returns URL protocol (http or https).

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL