minio

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

Minio

A Minio disk driver for facades.Storage of Goravel.

Version

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

Install

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

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

"disks": map[string]any{
    ...
    "minio": map[string]any{
        "driver": "custom",
        "key":      config.Env("MINIO_ACCESS_KEY_ID"),
        "secret":   config.Env("MINIO_ACCESS_KEY_SECRET"),
        "region":   config.Env("MINIO_REGION"),
        "bucket":   config.Env("MINIO_BUCKET"),
        "url":      config.Env("MINIO_URL"),
        "endpoint": config.Env("MINIO_ENDPOINT"),
        "ssl":      config.Env("MINIO_SSL", false),
        "via": func() (filesystem.Driver, error) {
            return miniofacades.Minio("minio"), nil // The `minio` value is the `disks` key
        },
    },
}

Testing

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

MINIO_ACCESS_KEY_ID= MINIO_ACCESS_KEY_SECRET= MINIO_BUCKET= go test ./...

Documentation

Index

Constants

View Source
const Binding = "goravel.minio"

Variables

Functions

This section is empty.

Types

type Minio

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

func NewMinio

func NewMinio(ctx context.Context, config config.Config, disk string) (*Minio, error)

func (*Minio) AllDirectories

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

func (*Minio) AllFiles

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

func (*Minio) Copy

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

func (*Minio) Delete

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

func (*Minio) DeleteDirectory

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

func (*Minio) Directories

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

func (*Minio) Exists

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

func (*Minio) Files

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

func (*Minio) Get

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

func (*Minio) GetBytes added in v1.1.1

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

func (*Minio) LastModified

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

func (*Minio) MakeDirectory

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

func (*Minio) MimeType

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

func (*Minio) Missing

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

func (*Minio) Move

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

func (*Minio) Path

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

func (*Minio) Put

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

func (*Minio) PutFile

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

func (*Minio) PutFileAs

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

func (*Minio) Size

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

func (*Minio) TemporaryUrl

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

func (*Minio) Url

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

func (*Minio) WithContext

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