An OSS disk driver for facades.Storage()
of Goravel.
goravel/oss | goravel/framework |
---|---|
v1.2.* | v1.14.* |
v1.1.* | v1.13.* |
v1.0.* | v1.12.* |
- Add package
go get -u github.com/goravel/oss
- Register service provider
// config/app.go
import "github.com/goravel/oss"
"providers": []foundation.ServiceProvider{
...
&oss.ServiceProvider{},
}
- Add oss disk to
config/filesystems.go
file
// config/filesystems.go
import (
"github.com/goravel/framework/contracts/filesystem"
ossfacades "github.com/goravel/oss/facades"
)
"disks": map[string]any{
...
"oss": map[string]any{
"driver": "custom",
"key": config.Env("ALIYUN_ACCESS_KEY_ID"),
"secret": config.Env("ALIYUN_ACCESS_KEY_SECRET"),
"bucket": config.Env("ALIYUN_BUCKET"),
"url": config.Env("ALIYUN_URL"),
"endpoint": config.Env("ALIYUN_ENDPOINT"),
"via": func() (filesystem.Driver, error) {
return ossfacades.Oss("oss"), nil // The `oss` value is the `disks` key
},
},
}
Run command below to run test(fill your owner oss configuration):
ALIYUN_ACCESS_KEY_ID= ALIYUN_ACCESS_KEY_SECRET= ALIYUN_BUCKET= ALIYUN_URL= ALIYUN_ENDPOINT= go test ./...