s3

package module
v1.0.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 22, 2024 License: Apache-2.0 Imports: 22 Imported by: 0

README

CDN With S3 Storage (preview)

This plugin can be used to store static files to AWS S3.

How to use

Build
./answer build --with github.com/answerdev/plugins/cdn-s3
Configuration
  • Endpoint - Endpoint of the AWS S3 storage
  • Bucket Name - Your bucket name
  • Object Key Prefix - Prefix of the object key like 'static/' that ending with '/'
  • Access Key Id - AccessKeyId of the S3
  • Access Key Secret - AccessKeySecret of the S3
  • Access Token - AccessToken of the S3
  • Visit Url Prefix - Prefix of access address for the static file, ending with '/' such as https://static.example.com/xxx/
  • Max File Size - Max file size in MB, default is 10MB

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Info embed.FS

Functions

This section is empty.

Types

type CDN

type CDN struct {
	Config *CDNConfig
	Client *Client
}

func (*CDN) CheckFileType

func (c *CDN) CheckFileType(filePath string) bool

func (*CDN) ConfigFields

func (c *CDN) ConfigFields() []plugin.ConfigField

func (*CDN) ConfigReceiver

func (c *CDN) ConfigReceiver(config []byte) error

func (*CDN) GetStaticPrefix

func (c *CDN) GetStaticPrefix() string

GetStaticPrefix get static prefix

func (*CDN) Info

func (c *CDN) Info() plugin.Info

func (*CDN) Upload

func (c *CDN) Upload(filePath string, file io.ReadSeeker, size int64) (err error)

type CDNConfig

type CDNConfig struct {
	Endpoint        string `json:"endpoint"`
	BucketName      string `json:"bucket_name"`
	ObjectKeyPrefix string `json:"object_key_prefix"`
	AccessKeyID     string `json:"access_key_id"`
	AccessKeySecret string `json:"access_key_secret"`
	AccessToken     string `json:"access_token"`
	VisitUrlPrefix  string `json:"visit_url_prefix"`
	MaxFileSize     string `json:"max_file_size"`
	Region          string `json:"region"`
	DisableSSL      bool   `json:"disable_ssl"`
}

type Client

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

func NewS3Client

func NewS3Client(id, secret, token, endpoint, region, bucket string, disableSSL bool) *Client

func (*Client) PutObject

func (s *Client) PutObject(key, ext string, file io.ReadSeeker) (err error)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL