image

package
v0.0.0-...-2432eff Latest Latest
Warning

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

Go to latest
Published: May 1, 2025 License: MIT Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ImageHandler

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

func NewImageHandler

func NewImageHandler(service *Service) *ImageHandler

func (*ImageHandler) UploadImage

func (h *ImageHandler) UploadImage(c *gin.Context)

UploadImage godoc @Summary Upload an image @Description Uploads and processes an image, returning its URL @Tags Images @Accept multipart/form-data @Produce json @Param image formData file true "Image file to upload" @Success 200 {object} map[string]string "url" @Failure 400 {object} myerr.ErrorResponse "Bad Request (e.g., no file, invalid file type)" @Failure 500 {object} myerr.ErrorResponse "Internal Server Error" @Router /admin/images/upload [post]

type LocalStorage

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

LocalStorage implements Storage interface for local filesystem

func NewLocalStorage

func NewLocalStorage(basePath, baseURL string) *LocalStorage

func (*LocalStorage) Delete

func (s *LocalStorage) Delete(filename string) error

func (*LocalStorage) GetURL

func (s *LocalStorage) GetURL(filename string) string

func (*LocalStorage) Save

func (s *LocalStorage) Save(data []byte, filename string) error

type ProcessConfig

type ProcessConfig struct {
	MaxWidth     int
	MaxHeight    int
	Quality      int
	AllowedTypes []string
}

type Service

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

func NewService

func NewService(storage Storage, config ProcessConfig) *Service

func (*Service) DeleteImage

func (s *Service) DeleteImage(filename string) error

func (*Service) GetImageURL

func (s *Service) GetImageURL(filename string) string

func (*Service) SaveImage

func (s *Service) SaveImage(file *multipart.FileHeader) (string, error)

type Storage

type Storage interface {
	Save(data []byte, filename string) error
	Delete(filename string) error
	GetURL(filename string) string
}

Storage defines the interface for image storage operations

Jump to

Keyboard shortcuts

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