cloudinary

package module
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: Sep 11, 2023 License: MIT Imports: 19 Imported by: 0

README

cloudinary

A cloudinary driver for facades.Storage() of Goravel.

Version

goravel/cloudinary cloudinary goravel/framework
v1.1.* v2.4.0 v1.13.*

Install

  1. Add package
go get github.com/goravel/cloudinary
  1. Register service provider
// config/app.go
import "github.com/goravel/cloudinary"

"providers": []foundation.ServiceProvider{
    ...
    &cloudinary.ServiceProvider{},
}
  1. Add cloudinary disk to config/filesystems.go file
// config/filesystems.go
...

import (
     cloudinaryfacades "github.com/goravel/cloudinary/facades"
     "github.com/goravel/framework/filesystem"
)

"disks": map[string]filesystem.Disk{
     ...
     "cloudinary": map[string]any{
           "driver": "custom",
           "cloud":  config.Env("CLOUDINARY_CLOUD"),
           "key":    config.Env("CLOUDINARY_ACCESS_KEY_ID"),
           "secret": config.Env("CLOUDINARY_ACCESS_KEY_SECRET"),
           // resource_types is optional
           // it is used to limit the types of files that can be uploaded to cloudinary disk
           "resource_types": map[string][]string{
                "image": {"png"},
                "video": {},
                "raw":   {"txt", "pdf"},
           },
           "via": func()(filestystem.Disk, error) {
                 return cloudinaryfacades.Cloudinary("cloudinary"), nil // The `cloudinary` value is the `disks` key
           },
     }
}

Documentation

Index

Constants

View Source
const Binding = "goravel.cloudinary"

Variables

Functions

func GetRawContent

func GetRawContent(url string) ([]byte, error)

GetRawContent retrieves the raw content of a file from the provided URL.

Types

type Cloudinary

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

func NewCloudinary

func NewCloudinary(ctx context.Context, config config.Config, disk string) (*Cloudinary, error)

func (*Cloudinary) AllDirectories

func (r *Cloudinary) AllDirectories(path string) ([]string, error)

AllDirectories returns all the directories within a given directory and all its subdirectories.

func (*Cloudinary) AllFiles

func (r *Cloudinary) AllFiles(path string) ([]string, error)

AllFiles returns all the files from the given directory including all its subdirectories.

func (*Cloudinary) Copy

func (r *Cloudinary) Copy(source, destination string) error

Copy copies a file to a new location.

func (*Cloudinary) Delete

func (r *Cloudinary) Delete(file ...string) error

Delete deletes a file.

func (*Cloudinary) DeleteDirectory

func (r *Cloudinary) DeleteDirectory(directory string) error

DeleteDirectory deletes a directory.

func (*Cloudinary) Directories

func (r *Cloudinary) Directories(path string) ([]string, error)

Directories return all the directories within a given directory.

func (*Cloudinary) Exists

func (r *Cloudinary) Exists(file string) bool

Exists checks if a file exists in the Cloudinary storage.

func (*Cloudinary) Files

func (r *Cloudinary) Files(path string) ([]string, error)

Files returns all the files from the given directory.

func (*Cloudinary) Get

func (r *Cloudinary) Get(file string) (string, error)

Get returns the contents of a file.

func (*Cloudinary) LastModified

func (r *Cloudinary) LastModified(file string) (time.Time, error)

LastModified returns the last modified time of a file.

func (*Cloudinary) MakeDirectory

func (r *Cloudinary) MakeDirectory(directory string) error

MakeDirectory creates a directory.

func (*Cloudinary) MimeType

func (r *Cloudinary) MimeType(file string) (string, error)

MimeType returns the mime-type of a file.

func (*Cloudinary) Missing

func (r *Cloudinary) Missing(file string) bool

Missing checks if a file is missing.

func (*Cloudinary) Move

func (r *Cloudinary) Move(source, destination string) error

Move moves a file to a new location.

func (*Cloudinary) Path

func (r *Cloudinary) Path(file string) string

Path returns the full path for a file.

func (*Cloudinary) Put

func (r *Cloudinary) Put(file, content string) error

Put stores a new file on the disk.

func (*Cloudinary) PutFile

func (r *Cloudinary) PutFile(path string, source filesystem.File) (string, error)

PutFile stores a new file on the disk.

func (*Cloudinary) PutFileAs

func (r *Cloudinary) PutFileAs(path string, source filesystem.File, name string) (string, error)

PutFileAs stores a new file on the disk.

func (*Cloudinary) Size

func (r *Cloudinary) Size(file string) (int64, error)

Size returns the file size of a given file.

func (*Cloudinary) TemporaryUrl

func (r *Cloudinary) TemporaryUrl(file string, time time.Time) (string, error)

TemporaryUrl get the temporary url of a file.

func (*Cloudinary) Url

func (r *Cloudinary) Url(file string) string

Url returns the url for a file.

func (*Cloudinary) WithContext

func (r *Cloudinary) WithContext(ctx context.Context) filesystem.Driver

WithContext sets the context for the driver.

type ServiceProvider

type ServiceProvider struct {
}

func (*ServiceProvider) Boot

func (receiver *ServiceProvider) Boot(app foundation.Application)

func (*ServiceProvider) Register

func (receiver *ServiceProvider) Register(app foundation.Application)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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