Documentation ¶
Overview ¶
Package cloudinary is an implementation of filestorage for Cloudinary
Index ¶
- type Cloudinary
- func (s *Cloudinary) Attributes(filepath string) (*filestorage.FileAttributes, error)
- func (s *Cloudinary) AttributesCtx(ctx context.Context, filepath string) (*filestorage.FileAttributes, error)
- func (s *Cloudinary) Delete(filepath string) error
- func (s *Cloudinary) DeleteCtx(ctx context.Context, filepath string) error
- func (s *Cloudinary) Exists(filepath string) (bool, error)
- func (s *Cloudinary) ExistsCtx(ctx context.Context, filepath string) (bool, error)
- func (s *Cloudinary) ID() string
- func (s *Cloudinary) Read(filepath string) (io.ReadCloser, error)
- func (s *Cloudinary) ReadCtx(ctx context.Context, filepath string) (io.ReadCloser, error)
- func (s *Cloudinary) SetAttributes(filepath string, attrs *filestorage.UpdatableFileAttributes) (*filestorage.FileAttributes, error)
- func (s *Cloudinary) SetAttributesCtx(ctx context.Context, filepath string, ...) (*filestorage.FileAttributes, error)
- func (s *Cloudinary) SetBucket(name string) error
- func (s *Cloudinary) URL(filepath string) (string, error)
- func (s *Cloudinary) URLCtx(ctx context.Context, filepath string) (string, error)
- func (s *Cloudinary) Write(src io.Reader, destPath string) error
- func (s *Cloudinary) WriteCtx(ctx context.Context, src io.Reader, destPath string) error
- func (s *Cloudinary) WriteIfNotExist(src io.Reader, destPath string) (new bool, url string, err error)
- func (s *Cloudinary) WriteIfNotExistCtx(ctx context.Context, src io.Reader, destPath string) (new bool, url string, err error)
- type Creator
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) 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 ¶
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) 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 ¶
NewCreator returns a filestorage creator that will use the provided keys to create a new cloudinary driver for each single logger