Documentation
¶
Overview ¶
Package s3service defines s3 operations available
Index ¶
- type MockS3Service
- func (m *MockS3Service) BulkDeleteFiles(ctx context.Context, uploadedKeys []string) int
- func (m *MockS3Service) BulkUploadFiles(ctx context.Context, payloads []*s3.PutObjectInput) ([]string, error)
- func (m *MockS3Service) DeleteFile(ctx context.Context, s3Path, filename, s3Key *string) error
- func (m *MockS3Service) DeleteKeys(ctx context.Context, keys []string) error
- func (m *MockS3Service) DeletePrefix(ctx context.Context, prefix string) error
- func (m *MockS3Service) FileExists(ctx context.Context, s3Path, filename string) (bool, error)
- func (m *MockS3Service) GeneratePreSignedDownloadURL(ctx context.Context, s3Path, filename string, expirationSeconds int64) (string, error)
- func (m *MockS3Service) GeneratePresignedURL(ctx context.Context, s3Key string, expiry time.Duration) (string, error)
- func (m *MockS3Service) GenerateUploadPayload(ctx context.Context, data []byte, s3Path, filename string, ...) (*s3.PutObjectInput, error)
- func (m *MockS3Service) UploadFile(ctx context.Context, data []byte, s3Path, filename string, ...) error
- type Service
- func (s *Service) BulkDeleteFiles(ctx context.Context, uploadedKeys []string) int
- func (s *Service) BulkUploadFiles(ctx context.Context, payloads []*s3.PutObjectInput) ([]string, error)
- func (s *Service) DeleteFile(ctx context.Context, s3Path, filename, s3Key *string) error
- func (s *Service) DeleteKeys(ctx context.Context, keys []string) error
- func (s *Service) DeletePrefix(ctx context.Context, prefix string) error
- func (s *Service) FileExists(ctx context.Context, s3Path, filename string) (bool, error)
- func (s *Service) GeneratePreSignedDownloadURL(ctx context.Context, s3Path, filename string, expirationSeconds int64) (string, error)
- func (s *Service) GeneratePresignedURL(ctx context.Context, s3Key string, expiry time.Duration) (string, error)
- func (s *Service) GenerateUploadPayload(ctx context.Context, data []byte, s3Path, filename string, ...) (*s3.PutObjectInput, error)
- func (s *Service) UploadFile(ctx context.Context, data []byte, s3Path, filename string, ...) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type MockS3Service ¶
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 ¶
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 ¶
NewS3Service creates a new S3 service instance
func (*Service) BulkDeleteFiles ¶
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 ¶
DeleteFile deletes a file from S3
func (*Service) DeleteKeys ¶
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 ¶
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 ¶
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