s3

package
v3.0.14-0...-6f456a8 Latest Latest
Warning

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

Go to latest
Published: Feb 26, 2025 License: MIT Imports: 22 Imported by: 0

README

AWS S3

AWS S3 backend for QOR OSS

Usage

import "github.com/qor/oss/aliyun"

func main() {
  storage := s3.New(s3.Config{
    AccessID: "access_id",
    AccessKey: "access_key",
    Region: "region",
    Bucket: "bucket",
    Endpoint: "cdn.getqor.com",
    ACL: awss3.BucketCannedACLPublicRead,
  })

  // Save a reader interface into storage
  storage.Put("/sample.txt", reader)

  // Get file with path
  storage.Get("/sample.txt")

  // Get object as io.ReadCloser
  storage.GetStream("/sample.txt")

  // Delete file with path
  storage.Delete("/sample.txt")

  // List all objects under path
  storage.List("/")

  // Get Public Accessible URL (useful if current file saved privately)
  storage.GetURL("/sample.txt")
}

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

type Client struct {
	S3     *s3.Client
	Config *Config
}

Client S3 storage

func New

func New(config *Config) *Client

New initialize S3 storage

func (Client) Copy

func (client Client) Copy(ctx context.Context, from, to string) (err error)

Copy copy s3 file from "from" to "to"

func (Client) Delete

func (client Client) Delete(ctx context.Context, path string) error

Delete delete file

func (Client) DeleteObjects

func (client Client) DeleteObjects(ctx context.Context, paths []string) (err error)

DeleteObjects delete files in bulk

func (Client) Get

func (client Client) Get(ctx context.Context, path string) (file *os.File, err error)

Get receive file with given path

func (Client) GetEndpoint

func (client Client) GetEndpoint(ctx context.Context) string

GetEndpoint get endpoint, FileSystem's endpoint is /

func (Client) GetStream

func (client Client) GetStream(ctx context.Context, path string) (io.ReadCloser, error)

GetStream get file as stream

func (Client) GetURL

func (client Client) GetURL(ctx context.Context, path string) (url string, err error)

GetURL get public accessible URL

func (Client) List

func (client Client) List(ctx context.Context, path string) ([]*oss.Object, error)

List list all objects under current path

func (Client) Put

func (client Client) Put(ctx context.Context, urlPath string, reader io.Reader) (*oss.Object, error)

Put store a reader into given path

func (Client) ToS3Key

func (client Client) ToS3Key(urlPath string) string

ToS3Key process path to s3 key

type Config

type Config struct {
	AccessID         string
	AccessKey        string
	Region           string
	Bucket           string
	SessionToken     string
	ACL              string
	Endpoint         string
	S3Endpoint       string
	S3ForcePathStyle bool
	CacheControl     string

	AWSConfig *aws.Config

	RoleARN string
}

Config S3 client config

Jump to

Keyboard shortcuts

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