oss

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

OSS

An OSS disk driver for facades.Storage() of Goravel.

Version

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

Install

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

"providers": []foundation.ServiceProvider{
    ...
    &oss.ServiceProvider{},
}
  1. 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
        },
    },
}

Testing

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 ./...

Documentation

Index

Constants

View Source
const Binding = "goravel.oss"
View Source
const MaxFileNum = 1000

Variables

Functions

This section is empty.

Types

type Oss

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

func NewOss

func NewOss(ctx context.Context, config config.Config, disk string) (*Oss, error)

func (*Oss) AllDirectories

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

func (*Oss) AllFiles

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

func (*Oss) Copy

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

func (*Oss) Delete

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

func (*Oss) DeleteDirectory

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

func (*Oss) Directories

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

func (*Oss) Exists

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

func (*Oss) Files

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

func (*Oss) Get

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

func (*Oss) GetBytes added in v1.1.1

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

func (*Oss) LastModified

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

func (*Oss) MakeDirectory

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

func (*Oss) MimeType

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

func (*Oss) Missing

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

func (*Oss) Move

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

func (*Oss) Path

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

func (*Oss) Put

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

func (*Oss) PutFile

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

func (*Oss) PutFileAs

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

func (*Oss) Size

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

func (*Oss) TemporaryUrl

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

func (*Oss) Url

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

func (*Oss) WithContext

func (r *Oss) 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