Documentation
¶
Index ¶
- func HasEndpointOverride() bool
- type Client
- func (c *Client) Copy(ctx context.Context, bucket, srcKey, dstKey string) *apierror.APIError
- func (c *Client) Delete(ctx context.Context, bucket, key string) *apierror.APIError
- func (c *Client) FileExists(ctx context.Context, bucket, key string) (bool, *apierror.APIError)
- func (c *Client) Get(ctx context.Context, bucket, key string) ([]byte, *apierror.APIError)
- func (c *Client) GetPresignedPutURL(ctx context.Context, bucket, key, contentType string, expiry time.Duration) (string, *apierror.APIError)
- func (c *Client) GetPresignedURL(ctx context.Context, bucket, key string, expiry time.Duration) (string, *apierror.APIError)
- func (c *Client) Upload(ctx context.Context, bucket, key string, body io.Reader, contentType string) *apierror.APIError
- type ObjectStore
- type StubClient
- func (s *StubClient) Copy(_ context.Context, _, _, _ string) *apierror.APIError
- func (s *StubClient) Delete(_ context.Context, _, _ string) *apierror.APIError
- func (s *StubClient) FileExists(_ context.Context, _, _ string) (bool, *apierror.APIError)
- func (s *StubClient) Get(_ context.Context, _, _ string) ([]byte, *apierror.APIError)
- func (s *StubClient) GetPresignedPutURL(_ context.Context, _, _, _ string, _ time.Duration) (string, *apierror.APIError)
- func (s *StubClient) GetPresignedURL(_ context.Context, _, _ string, _ time.Duration) (string, *apierror.APIError)
- func (s *StubClient) Upload(_ context.Context, _, _ string, _ io.Reader, _ string) *apierror.APIError
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func HasEndpointOverride ¶
func HasEndpointOverride() bool
HasEndpointOverride reports whether an S3-compatible endpoint is configured in place of AWS.
Types ¶
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client wraps the AWS S3 SDK client with convenience methods.
func NewClient ¶
NewClient creates a new S3 client using the given AWS region.
The EC2 IMDS credential provider is disabled: pods receive credentials via IRSA (web identity token), never the node instance role, and IMDS is unreachable from pods anyway (the node hop limit is pinned to 1 as MCP hardening). Leaving IMDS in the credential chain makes credential resolution block for the full request deadline (~5s) on every call when no other provider is configured, rather than failing fast.
func (*Client) Copy ¶
Copy copies an object within a bucket. The destination inherits SSE-AES256 from the bucket default. Idempotent: re-copying overwrites the destination, so an attach retry is safe.
func (*Client) Delete ¶
Delete removes an object from S3. S3 DeleteObject is idempotent — it returns success for a missing key — so this is safe to re-run after a partial purge.
func (*Client) FileExists ¶
FileExists checks whether an object exists in S3.
func (*Client) Get ¶
Get fetches an object's full bytes. The caller owns the returned slice; objects are expected to be modest (raw emails), so the whole body is read into memory.
func (*Client) GetPresignedPutURL ¶
func (c *Client) GetPresignedPutURL(ctx context.Context, bucket, key, contentType string, expiry time.Duration) (string, *apierror.APIError)
GetPresignedPutURL generates a presigned PUT URL for direct client upload. The client must send the same Content-Type header when uploading. SSE-AES256 is applied on the bucket default.
type ObjectStore ¶
type ObjectStore interface {
Upload(ctx context.Context, bucket, key string, body io.Reader, contentType string) *apierror.APIError
GetPresignedURL(ctx context.Context, bucket, key string, expiry time.Duration) (string, *apierror.APIError)
// GetPresignedPutURL generates a presigned PUT URL so a client can upload directly to the bucket, keeping large media off the API request path.
GetPresignedPutURL(ctx context.Context, bucket, key, contentType string, expiry time.Duration) (string, *apierror.APIError)
FileExists(ctx context.Context, bucket, key string) (bool, *apierror.APIError)
// Get fetches an object's full bytes. Used to read a raw inbound email the SES receipt rule stored.
Get(ctx context.Context, bucket, key string) ([]byte, *apierror.APIError)
// Delete removes an object. It is idempotent: deleting an already-absent key is not an error, so a reaper can re-attempt after a crash between the object delete and the DB row delete.
Delete(ctx context.Context, bucket, key string) *apierror.APIError
// Copy copies an object within a bucket (srcKey → dstKey). Used to promote a staged upload to its permanent key on attach; it is idempotent (re-copying overwrites the destination).
Copy(ctx context.Context, bucket, srcKey, dstKey string) *apierror.APIError
}
ObjectStore defines the interface for object storage operations.
type StubClient ¶
type StubClient struct {
FileExistsResult bool
// GetResult is the byte payload returned by Get (e.g. a canned raw email for inbound-bridge tests).
GetResult []byte
}
StubClient is a no-op ObjectStore implementation for use in test mode. FileExistsResult controls what FileExists reports: it defaults to false (so photo/label lookups behave as "absent"), but a service that needs uploads to validate as present in test mode (e.g. chat attachments) can set it to true.