Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Generate ¶
Generate creates a thumbnail from the provided image data. It resizes the image to fit within maxWidth x maxHeight while preserving aspect ratio, and returns the thumbnail as PNG bytes.
func IsSupportedFormat ¶
IsSupportedFormat checks if the given file extension supports thumbnail generation
func ProcessAsync ¶
func ProcessAsync(task *ThumbnailUploadTask, uploadFunc UploadFunc)
ProcessAsync processes a thumbnail upload task asynchronously. The uploadFunc parameter should contain the logic to upload the thumbnail and register it with the API.
Types ¶
type Config ¶
Config holds thumbnail generation settings
func DefaultConfig ¶
func DefaultConfig() *Config
type CreateThumbnailRequest ¶
type CreateThumbnailRequest struct {
FileUUID string `json:"fileUuid"`
MaxWidth int `json:"maxWidth"`
MaxHeight int `json:"maxHeight"`
Type string `json:"type"`
Size int64 `json:"size"`
BucketID string `json:"bucketId"`
BucketFile string `json:"bucketFile"`
EncryptVersion string `json:"encryptVersion"`
}
CreateThumbnailRequest matches the API payload structure for POST /drive/files/thumbnail
func CreateThumbnailMetadata ¶
func CreateThumbnailMetadata(fileUUID, bucketID, bucketFile, encryptVersion string, size int64, cfg *Config) CreateThumbnailRequest
CreateThumbnailMetadata creates the metadata struct for registering a thumbnail.
type ThumbnailUploadTask ¶
type ThumbnailUploadTask struct {
Ctx context.Context
FileUUID string
FileType string
OriginalData []byte
}
ThumbnailUploadTask represents a task to upload a thumbnail asynchronously.
type UploadFunc ¶
type UploadFunc func(ctx context.Context, task *ThumbnailUploadTask) error
UploadFunc is a function type that handles the actual upload of a thumbnail. This allows dependency injection to avoid circular imports.