cloudinary

package module
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Jan 6, 2021 License: MIT Imports: 3 Imported by: 71

README

Cloudinary Go SDK

Cloudinary is a cloud service that offers a solution to a web application's entire image management pipeline.

Easily upload images to the cloud. Automatically perform smart image resizing, cropping and conversion without installing any complex software. Integrate Facebook or Twitter profile image extraction in a snap, in any dimension and style to match your website's graphics requirements. Images are seamlessly delivered through a fast CDN, and much much more.

Cloudinary offers comprehensive APIs and administration capabilities and is easy to integrate with any web application, existing or new.

Cloudinary provides URL and HTTP based APIs that can be easily integrated with any Web development framework.

For Go, Cloudinary provides a module for simplifying the integration even further.

Setup

To install Cloudinary Go SDK, use go get:

go get github.com/cloudinary/cloudinary-go

Usage

Configuration

Each request for building a URL of a remote cloud resource must have the CloudName parameter set. Each request to our secure APIs (e.g., image uploads, eager sprite generation) must have the ApiKey and ApiSecret parameters set. See API, URLs and access identifiers for more details.

Setting the CloudName, ApiKey and ApiSecret parameters can be done by initializing the Cloudinary object, or by using the CLOUDINARY_URL environment variable / system property.

The entry point of the library is the Cloudinary struct.

cld, _ := cloudinary.Create()

Here's an example of setting the configuration parameters programatically:

cld, _ := cloudinary.CreateFromParams('n07t21i7','123456789012345', 'abcdeghijklmnopqrstuvwxyz12')

Another example of setting the configuration parameters by providing the CLOUDINARY_URL value:

cld, _ := cloudinary.CreateFromUrl('cloudinary://123456789012345:abcdeghijklmnopqrstuvwxyz12@n07t21i7')
Upload

Assuming you have your Cloudinary configuration parameters defined (CloudName, ApiKey, ApiSecret), uploading to Cloudinary is very simple.

The following example uploads a local JPG to the cloud:

resp, err := cld.Upload.Upload(ctx, "my_picture.jpg", uploader.UploadParams{});

The uploaded image is assigned a randomly generated public ID. The image is immediately available for a download through a CDN:

println(resp.SecureURL)

// https://res.cloudinary.com/demo/image/upload/abcfrmo8zul1mafopawefg.jpg

You can also specify your own public ID:

resp, err := cld.Upload.Upload(ctx, "my_picture.jpg", uploader.UploadParams{PublicID: "sample_remote.jpg"});
if err != nil {...}
println(resp.SecureURL)

// https://res.cloudinary.com/demo/image/upload/sample_remote.jpg

Additional resources

Additional resources are available at:

Support

You can open an issue through GitHub.

Stay tuned for updates, tips and tutorials: Blog , Twitter, Facebook.

Join the Community

Impact the product, hear updates, test drive new features and more! Join here.

Staying up to date

To update Cloudinary Go SDK to the latest version, use go get -u github.com/cloudinary/cloudinary-go.

Contributing

Please feel free to submit issues, fork the repository and send pull requests!

When submitting an issue, we ask that you please include a complete test function that demonstrates the issue.

License

Released under the MIT license.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Cloudinary

type Cloudinary struct {
	Config config.Configuration
	Admin  admin.Api
	Upload uploader.Api
}

Cloudinary main struct

func Create

func Create() (*Cloudinary, error)

Create returns a new Cloudinary instance from environment variable.

func CreateFromConfiguration

func CreateFromConfiguration(configuration config.Configuration) (*Cloudinary, error)

CreateFromConfiguration returns a new Cloudinary instance from the provided configuration.

func CreateFromParams

func CreateFromParams(cloud string, key string, secret string) (*Cloudinary, error)

CreateFromParams returns a new Cloudinary instance from the provided parameters.

func CreateFromUrl

func CreateFromUrl(cloudinaryUrl string) (*Cloudinary, error)

CreateFromUrl returns a new Cloudinary instance from a cloudinary url.

Directories

Path Synopsis
api
Package api contains packages used for accessing Cloudinary API functionality.
Package api contains packages used for accessing Cloudinary API functionality.
admin
Package admin is used for accessing Cloudinary Admin API functionality.
Package admin is used for accessing Cloudinary Admin API functionality.
admin/metadata
Package metadata defines the structured metadata.
Package metadata defines the structured metadata.
uploader
Package uploader is used for accessing Cloudinary Upload API functionality.
Package uploader is used for accessing Cloudinary Upload API functionality.
Package config defines the Cloudinary configuration.
Package config defines the Cloudinary configuration.
example module
Package transformation defines Cloudinary Transformation.
Package transformation defines Cloudinary Transformation.

Jump to

Keyboard shortcuts

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