README
¶
COS
A COS disk driver for facades.Storage()
of Goravel.
Version
goravel/cos | goravel/framework |
---|---|
v1.3.* | v1.15.* |
v1.2.* | v1.14.* |
v1.1.* | v1.13.* |
v1.0.* | v1.12.* |
Install
- Add package
go get -u github.com/goravel/cos
- Register service provider
// config/app.go
import "github.com/goravel/cos"
"providers": []foundation.ServiceProvider{
...
&cos.ServiceProvider{},
}
- 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
- Variables
- type Cos
- func (r *Cos) AllDirectories(path string) ([]string, error)
- func (r *Cos) AllFiles(path string) ([]string, error)
- func (r *Cos) Copy(originFile, targetFile string) error
- func (r *Cos) Delete(files ...string) error
- func (r *Cos) DeleteDirectory(directory string) error
- func (r *Cos) Directories(path string) ([]string, error)
- func (r *Cos) Exists(file string) bool
- func (r *Cos) Files(path string) ([]string, error)
- func (r *Cos) Get(file string) (string, error)
- func (r *Cos) GetBytes(file string) ([]byte, error)
- func (r *Cos) LastModified(file string) (time.Time, error)
- func (r *Cos) MakeDirectory(directory string) error
- func (r *Cos) MimeType(file string) (string, error)
- func (r *Cos) Missing(file string) bool
- func (r *Cos) Move(oldFile, newFile string) error
- func (r *Cos) Path(file string) string
- func (r *Cos) Put(file string, content string) error
- func (r *Cos) PutFile(filePath string, source filesystem.File) (string, error)
- func (r *Cos) PutFileAs(filePath string, source filesystem.File, name string) (string, error)
- func (r *Cos) Size(file string) (int64, error)
- func (r *Cos) TemporaryUrl(file string, time time.Time) (string, error)
- func (r *Cos) Url(file string) string
- func (r *Cos) WithContext(ctx context.Context) filesystem.Driver
- type ServiceProvider
Constants ¶
View Source
const Binding = "goravel.cos"
Variables ¶
View Source
var App foundation.Application
Functions ¶
This section is empty.
Types ¶
type Cos ¶
type Cos struct {
// contains filtered or unexported fields
}
func (*Cos) DeleteDirectory ¶
func (*Cos) MakeDirectory ¶
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)
Click to show internal directories.
Click to hide internal directories.