s3service

package
v0.17.0 Latest Latest
Warning

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

Go to latest
Published: Nov 16, 2026 License: AGPL-3.0 Imports: 17 Imported by: 0

Documentation

Overview

Package s3service defines s3 operations available

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type MockS3Service

type MockS3Service struct {
	mock.Mock
}

MockS3Service provides a mock implementation of S3Service

func (*MockS3Service) BulkDeleteFiles

func (m *MockS3Service) BulkDeleteFiles(ctx context.Context, uploadedKeys []string) int

BulkDeleteFiles deletes multiple files from S3

func (*MockS3Service) BulkUploadFiles

func (m *MockS3Service) BulkUploadFiles(ctx context.Context, payloads []*s3.PutObjectInput) ([]string, error)

BulkUploadFiles uploads multiple files given a list of payloads

func (*MockS3Service) DeleteFile

func (m *MockS3Service) DeleteFile(ctx context.Context, s3Path, filename, s3Key *string) error

DeleteFile deletes a file from S3

func (*MockS3Service) DeleteKeys

func (m *MockS3Service) DeleteKeys(ctx context.Context, keys []string) error

DeleteKeys deletes the given keys

func (*MockS3Service) DeletePrefix

func (m *MockS3Service) DeletePrefix(ctx context.Context, prefix string) error

DeletePrefix deletes every object under prefix

func (*MockS3Service) FileExists

func (m *MockS3Service) FileExists(ctx context.Context, s3Path, filename string) (bool, error)

FileExists checks if a file exists in S3

func (*MockS3Service) GeneratePreSignedDownloadURL

func (m *MockS3Service) GeneratePreSignedDownloadURL(ctx context.Context, s3Path, filename string, expirationSeconds int64) (string, error)

GeneratePreSignedDownloadURL generates a presigned download URL

func (*MockS3Service) GeneratePresignedURL

func (m *MockS3Service) GeneratePresignedURL(ctx context.Context, s3Key string, expiry time.Duration) (string, error)

GeneratePresignedURL generates a presigned URL for the given S3 key

func (*MockS3Service) GenerateUploadPayload

func (m *MockS3Service) GenerateUploadPayload(ctx context.Context, data []byte, s3Path, filename string, metadata map[string]string) (*s3.PutObjectInput, error)

GenerateUploadPayload generates a payload for uploading a file to S3

func (*MockS3Service) UploadFile

func (m *MockS3Service) UploadFile(ctx context.Context, data []byte, s3Path, filename string, metadata map[string]string) error

UploadFile uploads a file to S3 with the given path and filename

type Service

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

Service provides methods for interacting with AWS S3

func NewS3Service

func NewS3Service() (*Service, error)

NewS3Service creates a new S3 service instance

func (*Service) BulkDeleteFiles

func (s *Service) BulkDeleteFiles(ctx context.Context, uploadedKeys []string) int

BulkDeleteFiles deletes multiple files from S3 one by one and returns how many deletes failed, so callers can tell an orphaned object from a clean delete.

func (*Service) BulkUploadFiles

func (s *Service) BulkUploadFiles(ctx context.Context, payloads []*s3.PutObjectInput) ([]string, error)

BulkUploadFiles uploads multiple files given a list of payloads. Auto rollback if there are errors

func (*Service) DeleteFile

func (s *Service) DeleteFile(ctx context.Context, s3Path, filename, s3Key *string) error

DeleteFile deletes a file from S3

func (*Service) DeleteKeys

func (s *Service) DeleteKeys(ctx context.Context, keys []string) error

DeleteKeys deletes every key, in DeleteObjects batches. A key that does not exist counts as deleted. It returns an error if any key could not be deleted; the others are deleted anyway, so a retry only has the rest to do.

func (*Service) DeletePrefix

func (s *Service) DeletePrefix(ctx context.Context, prefix string) error

DeletePrefix deletes every object whose key starts with prefix. The prefix must end with "/" so that "a/u1/" never matches "a/u10/...". It stops at the first page with a failed delete and reports it; a retry deletes the rest.

func (*Service) FileExists

func (s *Service) FileExists(ctx context.Context, s3Path, filename string) (bool, error)

FileExists checks if a file exists in S3

func (*Service) GeneratePreSignedDownloadURL

func (s *Service) GeneratePreSignedDownloadURL(ctx context.Context, s3Path, filename string, expirationSeconds int64) (string, error)

GeneratePreSignedDownloadURL generates a pre-signed URL for downloading a file from S3 The URL will be valid for the specified duration (in seconds)

func (*Service) GeneratePresignedURL

func (s *Service) GeneratePresignedURL(ctx context.Context, s3Key string, expiry time.Duration) (string, error)

GeneratePresignedURL generates a short-lived S3 GET URL for the given full object key.

func (*Service) GenerateUploadPayload

func (s *Service) GenerateUploadPayload(ctx context.Context, data []byte, s3Path, filename string, metadata map[string]string) (*s3.PutObjectInput, error)

GenerateUploadPayload generates a payload for uploading a file to S3 have the same signature as UploadFile, but return the payload instead of uploading for bulk upload

func (*Service) UploadFile

func (s *Service) UploadFile(ctx context.Context, data []byte, s3Path, filename string, metadata map[string]string) error

UploadFile uploads a file to S3 with the given path and filename metadata is optional - if nil, no metadata will be added

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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