cloudinary

package
v0.0.0-...-4cce589 Latest Latest
Warning

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

Go to latest
Published: Dec 28, 2017 License: MIT Imports: 17 Imported by: 0

Documentation

Overview

Package cloudinary is an implementation of filestorage for Cloudinary

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Cloudinary

type Cloudinary struct {
	// contains filtered or unexported fields
}

Cloudinary is an implementation of the FileStorage interface for Cloudinary

func New

func New(apiKey, secret string) *Cloudinary

New returns a new instance of a Cloudinary Storage

func NewWithContext

func NewWithContext(ctx context.Context, apiKey, secret string) *Cloudinary

NewWithContext returns a new instance of a Cloudinary Storage attached to the provided context

func (*Cloudinary) Attributes

func (s *Cloudinary) Attributes(filepath string) (*filestorage.FileAttributes, error)

Attributes returns the attributes of the file Will use the defaut context

func (*Cloudinary) AttributesCtx

func (s *Cloudinary) AttributesCtx(ctx context.Context, filepath string) (*filestorage.FileAttributes, error)

AttributesCtx returns the attributes of the file

func (*Cloudinary) Delete

func (s *Cloudinary) Delete(filepath string) error

Delete removes a file, ignores files that do not exist Will use the defaut context

func (*Cloudinary) DeleteCtx

func (s *Cloudinary) DeleteCtx(ctx context.Context, filepath string) error

DeleteCtx removes a file Because Cloudinary forces to have the file type in the URL, this method brutforces on all the possible types

func (*Cloudinary) Exists

func (s *Cloudinary) Exists(filepath string) (bool, error)

Exists check if a file exists Will use the defaut context

func (*Cloudinary) ExistsCtx

func (s *Cloudinary) ExistsCtx(ctx context.Context, filepath string) (bool, error)

ExistsCtx check if a file exists

func (*Cloudinary) ID

func (s *Cloudinary) ID() string

ID returns the unique identifier of the storage provider

func (*Cloudinary) Read

func (s *Cloudinary) Read(filepath string) (io.ReadCloser, error)

Read fetches a file a returns a reader Will use the defaut context

func (*Cloudinary) ReadCtx

func (s *Cloudinary) ReadCtx(ctx context.Context, filepath string) (io.ReadCloser, error)

ReadCtx fetches a file a returns a reader Because Cloudinary forces to have the file type in the URL, this method brutforces on all the possible types

func (*Cloudinary) SetAttributes

func (s *Cloudinary) SetAttributes(filepath string, attrs *filestorage.UpdatableFileAttributes) (*filestorage.FileAttributes, error)

SetAttributes sets the attributes of the file Will use the defaut context

func (*Cloudinary) SetAttributesCtx

func (s *Cloudinary) SetAttributesCtx(ctx context.Context, filepath string, attrs *filestorage.UpdatableFileAttributes) (*filestorage.FileAttributes, error)

SetAttributesCtx sets the attributes of the file

func (*Cloudinary) SetBucket

func (s *Cloudinary) SetBucket(name string) error

SetBucket is used to set the bucket Always return nil

func (*Cloudinary) URL

func (s *Cloudinary) URL(filepath string) (string, error)

URL returns the URL of the file Will use the defaut context

func (*Cloudinary) URLCtx

func (s *Cloudinary) URLCtx(ctx context.Context, filepath string) (string, error)

URLCtx returns the URL of the file Because Cloudinary forces to have the file type in the URL, this method tries to download the file using each types until it finds the right URL

func (*Cloudinary) Write

func (s *Cloudinary) Write(src io.Reader, destPath string) error

Write copy the provided os.File to dest Will use the defaut context

func (*Cloudinary) WriteCtx

func (s *Cloudinary) WriteCtx(ctx context.Context, src io.Reader, destPath string) error

WriteCtx copy the provided os.File to dest

func (*Cloudinary) WriteIfNotExist

func (s *Cloudinary) WriteIfNotExist(src io.Reader, destPath string) (new bool, url string, err error)

WriteIfNotExist copies the provided io.Reader to dest if the file does not already exist Returns:

  • A boolean specifying if the file got uploaded (true) or if already existed (false).
  • A URL to the uploaded file
  • An error if something went wrong

Will use the defaut context

func (*Cloudinary) WriteIfNotExistCtx

func (s *Cloudinary) WriteIfNotExistCtx(ctx context.Context, src io.Reader, destPath string) (new bool, url string, err error)

WriteIfNotExistCtx copies the provided io.Reader to dest if the file does not already exist Returns:

  • A boolean specifying if the file got uploaded (true) or if already existed (false).
  • A URL to the uploaded file
  • An error if something went wrong

type Creator

type Creator struct {
	// contains filtered or unexported fields
}

Creator creates new filestorage

func NewCreator

func NewCreator(apiKey, secret, defaultBucket string) *Creator

NewCreator returns a filestorage creator that will use the provided keys to create a new cloudinary driver for each single logger

func (*Creator) New

func (c *Creator) New() (filestorage.FileStorage, error)

New returns a new le client

func (*Creator) NewWithContext

func (c *Creator) NewWithContext(ctx context.Context) (filestorage.FileStorage, error)

NewWithContext returns a new gc storage client using the provided context as default context instead of the one provided during the creation of the Creator

Jump to

Keyboard shortcuts

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