s3

package module
v1.2.6 Latest Latest
Warning

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

Go to latest
Published: Apr 3, 2024 License: Apache-2.0 Imports: 16 Imported by: 0

README

S3 Storage (preview)

This plugin can be used to store attachments and avatars to AWS S3.

How to use

Build
./answer build --with github.com/apache/incubator-answer-plugins/storage-s3
Configuration
  • Endpoint - Endpoint of the AWS S3 storage
  • Bucket Name - Your bucket name
  • Object Key Prefix - Prefix of the object key like 'answer/data/' 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 uploaded file, ending with '/' such as https://example.com/xxx/
  • Max File Size - Max file size in MB, default is 10MB

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

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)

type Storage

type Storage struct {
	Config *StorageConfig
	Client *Client
}

func (*Storage) ConfigFields

func (s *Storage) ConfigFields() []plugin.ConfigField

func (*Storage) ConfigReceiver

func (s *Storage) ConfigReceiver(config []byte) error

func (*Storage) Info

func (s *Storage) Info() plugin.Info

func (*Storage) UploadFile

func (s *Storage) UploadFile(ctx *plugin.GinContext, source plugin.UploadSource) (resp plugin.UploadFileResponse)

type StorageConfig

type StorageConfig 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"`
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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