store

package
v0.0.0-...-0bc2699 Latest Latest
Warning

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

Go to latest
Published: Aug 22, 2022 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ChecksumAlgorithm

type ChecksumAlgorithm = types.ChecksumAlgorithm

ChecksumAlgorithm defines the algorithm used to generate a checksum when verifying uploads to the storage backend.

type Client

type Client interface {
	PutObject(
		ctx context.Context,
		input *s3.PutObjectInput,
		optFns ...func(*s3.Options),
	) (*s3.PutObjectOutput, error)
	CreateMultipartUpload(
		ctx context.Context,
		input *s3.CreateMultipartUploadInput,
		optFns ...func(*s3.Options),
	) (*s3.CreateMultipartUploadOutput, error)
	UploadPart(
		ctx context.Context,
		input *s3.UploadPartInput,
		optFns ...func(*s3.Options),
	) (*s3.UploadPartOutput, error)
	CompleteMultipartUpload(
		ctx context.Context,
		input *s3.CompleteMultipartUploadInput,
		optFns ...func(*s3.Options),
	) (*s3.CompleteMultipartUploadOutput, error)
}

Client is the interface required to interact with a storage backend.

type CompleteMultipartUploadInput

type CompleteMultipartUploadInput s3.CompleteMultipartUploadInput

CompleteMultipartUploadInput defines the input data required to finalise a multi-part file.

type CreateMultipartUploadInput

type CreateMultipartUploadInput s3.CreateMultipartUploadInput

CreateMultipartUploadInput defines the input data required to initiate a multi-part file.

type DeleteObjectInput

type DeleteObjectInput s3.DeleteObjectInput

DeleteObjectInput defines the input data required to delete a file.

type File

type File struct {
	Key               string
	Bucket            string
	ChecksumAlgorithm ChecksumAlgorithm
	StorageClass      StorageClass
	File              fs.File
}

File encapsulates all information about a particular file required by the storage client.

func NewFileFromDomain

func NewFileFromDomain(
	domainFile *processor.File,
	checksumAlgorithm ChecksumAlgorithm,
	storageClass StorageClass,
	file fs.File,
) *File

NewFileFromDomain creates a store file model from the provided domain file and checksum algorithm.

func (*File) Size

func (f *File) Size() (int64, error)

Size returns the size of the file.

func (*File) ToCompleteMultipartUploadInput

func (f *File) ToCompleteMultipartUploadInput(
	uploadID string,
	parts []*UploadPartOutput,
) *CompleteMultipartUploadInput

ToCompleteMultipartUploadInput constructs an CompleteMultipartUploadInput from the file this method is called on.

func (*File) ToCreateMultipartUploadInput

func (f *File) ToCreateMultipartUploadInput() *CreateMultipartUploadInput

ToCreateMultipartUploadInput constructs a multi-part upload creation input from the file this method is called on.

func (*File) ToPutObjectInput

func (f *File) ToPutObjectInput() *PutObjectInput

ToPutObjectInput constructs an PutObjectInput from the file this method is called on.

func (*File) ToUploadPartInput

func (f *File) ToUploadPartInput(
	uploadID string,
	chunkNum int32,
	chunkSize int64,
) *UploadPartInput

ToUploadPartInput constructs an UploadPartInput from the file this method is called on.

type Option

type Option func(*Store)

Option defines the interface for configuring options on a Store instance.

func WithChecksumAlgorithm

func WithChecksumAlgorithm(algorithm ChecksumAlgorithm) Option

WithChecksumAlgorithm returns a Option that sets the checksum algorithm on the provided store.

func WithChunkSize

func WithChunkSize(chunksize int64) Option

WithChunkSize returns a Option that sets the chunk size on the provided store.

func WithStorageClass

func WithStorageClass(storageClass StorageClass) Option

WithStorageClass returns a Option that sets the checksum algorithm on the provided store.

type PutObjectInput

type PutObjectInput s3.PutObjectInput

PutObjectInput defines the input required to upload an object to a storage backend.

type StorageClass

type StorageClass = types.StorageClass

StorageClass denotes a particular storage class, as specified by the storage backend.

type Store

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

Store encapsulates the logic required to store a file in a storage bucket.

func New

func New(
	client Client,
	fs fs.FS,
	bucket string,
	opts ...Option,
) *Store

New instantiates a new file store with provided filesystem, uploader selector and checksum algorithm.

func (*Store) Upload

func (s *Store) Upload(ctx context.Context, file *processor.File) (*processor.File, error)

Upload stores the contents of the provided file file in the storage backend. The file is performed either as a single put operation or a multi-part file file, depending on the size of the file.

type UploadPartInput

type UploadPartInput s3.UploadPartInput

UploadPartInput defines the input data required to upload one part of a multi-part upload.

type UploadPartOutput

type UploadPartOutput s3.UploadPartOutput

UploadPartOutput defines the input data returned after uploading one part of a multi-part upload.

Directories

Path Synopsis
Package mocks is a generated GoMock package.
Package mocks is a generated GoMock package.

Jump to

Keyboard shortcuts

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