Documentation
¶
Index ¶
- func BuildObjectKey(projectID, tenantID, fileType, fileID, ext string) (string, error)
- func TenantObjectPrefix(projectID, tenantID string) (string, error)
- func ValidateTenantIDSegment(tenantID string) (string, error)
- type ObjectStorage
- type ProjectS3Storage
- func (s *ProjectS3Storage) DeleteObjects(ctx context.Context, keys []string) ([]string, error)
- func (s *ProjectS3Storage) DeletePrefix(ctx context.Context, prefix string) (int, []string, error)
- func (s *ProjectS3Storage) PublicURL(key string) string
- func (s *ProjectS3Storage) Upload(ctx context.Context, key string, body io.Reader, contentType string, ...) (string, error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func BuildObjectKey ¶
BuildObjectKey returns the canonical storage key. General: {project_id}/{file_type}/{uuid}{ext} SaaS (non-empty tenantID): {project_id}/{tenant_id}/{file_type}/{uuid}{ext}
func TenantObjectPrefix ¶ added in v1.8.4
TenantObjectPrefix returns the S3 key prefix for all objects belonging to a SaaS tenant. Example: "protiva_bqyu3/01KXZ…/"
func ValidateTenantIDSegment ¶ added in v1.8.4
ValidateTenantIDSegment returns a trimmed tenant id or an error when the value is unsafe for object keys.
Types ¶
type ObjectStorage ¶
type ObjectStorage interface {
Upload(ctx context.Context, key string, body io.Reader, contentType string, size int64) (publicURL string, err error)
DeleteObjects(ctx context.Context, keys []string) (failed []string, err error)
DeletePrefix(ctx context.Context, prefix string) (deleted int, failed []string, err error)
}
ObjectStorage uploads and deletes objects in project-configured S3-compatible storage.
type ProjectS3Storage ¶
type ProjectS3Storage struct {
// contains filtered or unexported fields
}
ProjectS3Storage implements ObjectStorage using aws-sdk-go-v2 and project storage settings.
func NewProjectS3Storage ¶
NewProjectS3Storage builds an S3-compatible client from project storage settings and platform free-cloud config.
func (*ProjectS3Storage) DeleteObjects ¶
DeleteObjects removes objects; returns keys that failed to delete.
func (*ProjectS3Storage) DeletePrefix ¶ added in v1.8.4
DeletePrefix lists all objects under prefix and deletes them.
func (*ProjectS3Storage) PublicURL ¶
func (s *ProjectS3Storage) PublicURL(key string) string
PublicURL builds the object URL from PublicBaseURL or endpoint/bucket/key.