cos

package module
v1.1.2 Latest Latest
Warning

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

Go to latest
Published: Oct 28, 2023 License: MIT Imports: 18 Imported by: 0

README

COS

A COS disk driver for facades.Storage() of Goravel.

Version

goravel/cos goravel/framework
v1.1.* v1.13.*
v1.0.* v1.12.*

Install

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

"providers": []foundation.ServiceProvider{
    ...
    &cos.ServiceProvider{},
}
  1. Add cos disk to config/filesystems.go file
// config/filesystems.go
import (
    "github.com/goravel/framework/contracts/filesystem"
    cosfacades "github.com/goravel/cos/facades"
)

"disks": map[string]any{
    ...
    "cos": map[string]any{
        "driver": "custom",
        "key":    config.Env("TENCENT_ACCESS_KEY_ID"),
        "secret": config.Env("TENCENT_ACCESS_KEY_SECRET"),
        "url":    config.Env("TENCENT_URL"),
        "via": func() (filesystem.Driver, error) {
            return cosfacades.Cos("cos"), nil // The `cos` value is the `disks` key
        },
    },
}

Testing

Run command below to run test(fill your owner cos configuration):

TENCENT_ACCESS_KEY_ID= TENCENT_ACCESS_KEY_SECRET= TENCENT_BUCKET= TENCENT_URL= go test ./...

Documentation

Index

Constants

View Source
const Binding = "goravel.cos"

Variables

Functions

This section is empty.

Types

type Cos

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

func NewCos

func NewCos(ctx context.Context, config config.Config, disk string) (*Cos, error)

func (*Cos) AllDirectories

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

func (*Cos) AllFiles

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

func (*Cos) Copy

func (r *Cos) Copy(originFile, targetFile string) error

func (*Cos) Delete

func (r *Cos) Delete(files ...string) error

func (*Cos) DeleteDirectory

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

func (*Cos) Directories

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

func (*Cos) Exists

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

func (*Cos) Files

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

func (*Cos) Get

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

func (*Cos) GetBytes added in v1.1.1

func (r *Cos) GetBytes(file string) ([]byte, error)

func (*Cos) LastModified

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

func (*Cos) MakeDirectory

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

func (*Cos) MimeType

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

func (*Cos) Missing

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

func (*Cos) Move

func (r *Cos) Move(oldFile, newFile string) error

func (*Cos) Path

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

func (*Cos) Put

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

func (*Cos) PutFile

func (r *Cos) PutFile(filePath string, source filesystem.File) (string, error)

func (*Cos) PutFileAs

func (r *Cos) PutFileAs(filePath string, source filesystem.File, name string) (string, error)

func (*Cos) Size

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

func (*Cos) TemporaryUrl

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

func (*Cos) Url

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

func (*Cos) WithContext

func (r *Cos) WithContext(ctx context.Context) filesystem.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