s3

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

utils_test.go# S3

A s3 disk driver for facades.Storage() of Goravel.

Version

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

Install

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

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

"disks": map[string]any{
    ...
    "s3": map[string]any{
        "driver": "custom",
        "key":    config.Env("AWS_ACCESS_KEY_ID"),
        "secret": config.Env("AWS_ACCESS_KEY_SECRET"),
        "region": config.Env("AWS_REGION"),
        "bucket": config.Env("AWS_BUCKET"),
        "url":    config.Env("AWS_URL"),
        "via": func() (filesystem.Driver, error) {
            return s3facades.S3("s3"), nil // The `s3` value is the `disks` key
        },
    },
}

Testing

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

AWS_ACCESS_KEY_ID= AWS_ACCESS_KEY_SECRET= AWS_DEFAULT_REGION= AWS_BUCKET= AWS_URL= go test ./...

Documentation

Index

Constants

View Source
const Binding = "goravel.s3"

Variables

Functions

This section is empty.

Types

type S3

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

func NewS3

func NewS3(ctx context.Context, config config.Config, disk string) (*S3, error)

func (*S3) AllDirectories

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

func (*S3) AllFiles

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

func (*S3) Copy

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

func (*S3) Delete

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

func (*S3) DeleteDirectory

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

func (*S3) Directories

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

func (*S3) Exists

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

func (*S3) Files

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

func (*S3) Get

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

func (*S3) GetBytes added in v1.1.1

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

func (*S3) LastModified

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

func (*S3) MakeDirectory

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

func (*S3) MimeType

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

func (*S3) Missing

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

func (*S3) Move

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

func (*S3) Path

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

func (*S3) Put

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

func (*S3) PutFile

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

func (*S3) PutFileAs

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

func (*S3) Size

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

func (*S3) TemporaryUrl

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

func (*S3) Url

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

func (*S3) WithContext

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