upload

package
v0.0.0-...-b3f093e Latest Latest
Warning

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

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

Documentation

Index

Constants

View Source
const AVStatusTagName = "av-status"

AVStatusTagName is the name of the tag that stores virus scan results for uploaded files

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	Bucket  string
	Region  string
	IsLocal bool
}

Config holds the configuration to interact with s3

type PreSignedURL

type PreSignedURL struct {
	URL      string `json:"URL"`
	Filename string `json:"filename"`
}

PreSignedURL is the model to return S3 pre-signed URLs

type S3Client

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

S3Client is an EASi s3 client wrapper

func NewS3Client

func NewS3Client(config Config) S3Client

NewS3Client creates a new s3 service client

func NewS3ClientUsingClient

func NewS3ClientUsingClient(s3Client s3iface.S3API, config Config) S3Client

NewS3ClientUsingClient creates a new s3 wrapper using the specified s3 client This is most useful for testing where the s3 client needs to be mocked out.

func (S3Client) GetBucket

func (c S3Client) GetBucket() string

GetBucket is a getter for the S3Client's configured bucket.

func (S3Client) KeyFromURL

func (c S3Client) KeyFromURL(url *url.URL) (string, error)

KeyFromURL strips the configured bucket name from a URL, returning only the S3 key.

This isn't always necessary for working with S3 buckets if they use virtual-hosted-style access, i.e. https://bucket-name.s3.region-code.amazonaws.com/key-name. However, MinIO by default uses path-style access, which puts the bucket name in the URL, i.e. https://s3.region-code.amazonaws.com/bucket-name/key-name. It's possible to configure MinIO to use virtual-hosted style, but it's tricky to get working with our current Docker Compose setup, so we don't bother with it. See https://docs.aws.amazon.com/AmazonS3/latest/userguide/access-bucket-intro.html and https://github.com/minio/minio/tree/master/docs/config#domain.

func (S3Client) NewGetPresignedURL

func (c S3Client) NewGetPresignedURL(key string) (*PreSignedURL, error)

NewGetPresignedURL returns a pre-signed URL used for GET-ing objects

func (S3Client) SetTagValueForKey

func (c S3Client) SetTagValueForKey(key string, tagName string, tagValue string) error

SetTagValueForKey sets the tag value and returns an error if any was encountered.

func (S3Client) TagValueForKey

func (c S3Client) TagValueForKey(key string, tagName string) (string, error)

TagValueForKey returns the tag value and if that tag was found for the specified key and tag name. If no value is found, returns an empty string.

func (S3Client) UploadFile

func (c S3Client) UploadFile(key string, body io.ReadSeeker) error

UploadFile uploads a file to the configured bucket for saving documents. Note that no file extension will be added to the key by this method; it assumes the caller has already added an extension, if desired.

Jump to

Keyboard shortcuts

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