A COS disk driver for facades.Storage()
of Goravel.
goravel/cos | goravel/framework |
---|---|
v1.2.* | v1.14.* |
v1.1.* | v1.13.* |
v1.0.* | v1.12.* |
- 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
},
},
}
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 ./...