Documentation
¶
Index ¶
- Constants
- func ByteToStream(data []byte) io.Reader
- func CheckToken(c *fiber.Ctx) error
- func CreateFile(file []byte) (*os.File, error)
- func DownloadFile(filepath string, url string) error
- func GetWidthAndHeight(c *fiber.Ctx, requestType string) (bool, uint, uint)
- func ImageToByte(img string) []byte
- func IsImageFile(filename string) bool
- func IsInt(one, two string) bool
- func MinioClient() *minio.Client
- func RandomName(length int) string
- func RatioWidthHeight(width, height, targetWidth, targetHeight uint) (uint, uint)
- func ReadEnvAndSet() error
- func Response(c *fiber.Ctx, code int, success bool, message string, data any) error
- func SanitizeObjectName(objectName string) string
- func SetWidthToHeight(width, height string) (string, string)
- func StreamToByte(stream io.Reader) []byte
- type AwsService
- type CacheService
- type ImageService
- func (s *ImageService) GetImage(bucket, objectName string, width, height int) ([]byte, error)
- func (s *ImageService) GetImageInfo(data []byte) (width uint, height uint, format string, err error)
- func (s *ImageService) ImagickFormat(image []byte) (error, string)
- func (s *ImageService) ImagickGetWidthHeight(image []byte) (error, uint, uint)
- func (s *ImageService) ImagickResize(image []byte, targetWidth, targetHeight uint) []byte
- func (s *ImageService) IsImageFile(data []byte) bool
- func (s *ImageService) IsResizable(data []byte) bool
- func (s *ImageService) ProcessImage(data []byte) ([]byte, error)
- func (s *ImageService) ResizeImage(data []byte, width, height int) ([]byte, error)
- type StatsService
- func (s *StatsService) AddUploadBytes(bytes int64)
- func (s *StatsService) DecrementActiveUploads()
- func (s *StatsService) GetActiveUploads() int
- func (s *StatsService) GetCPUUsage() float64
- func (s *StatsService) GetCacheHitRate() float64
- func (s *StatsService) GetDiskUsage() map[string]int64
- func (s *StatsService) GetMemoryUsage() float64
- func (s *StatsService) GetRecentErrors() []string
- func (s *StatsService) GetUploadSpeed() float64
- func (s *StatsService) IncrementActiveUploads()
- func (s *StatsService) IncrementCacheHit()
- func (s *StatsService) IncrementCacheMiss()
- func (s *StatsService) LogError(err string)
Constants ¶
const ( ParamsType = "params" FormsType = "forms" HeadersType = "headers" QueryType = "query" )
Variables ¶
This section is empty.
Functions ¶
func ByteToStream ¶
func CheckToken ¶
func DownloadFile ¶
func GetWidthAndHeight ¶
func ImageToByte ¶
func IsImageFile ¶
func MinioClient ¶
func RandomName ¶
func RatioWidthHeight ¶
func ReadEnvAndSet ¶ added in v1.2.2
func ReadEnvAndSet() error
func SanitizeObjectName ¶ added in v1.6.4
SanitizeObjectName removes or replaces unsupported characters for MinIO object names
func SetWidthToHeight ¶
func StreamToByte ¶
Types ¶
type AwsService ¶
type AwsService interface {
GlacierVaultList() *glacier.ListVaultsOutput
GlacierUploadArchive(vaultName string, fileBuffer []byte) (*glacier.UploadArchiveOutput, error)
GlacierInitiateRetrieval(vaultName, archiveId string, retrievalType string) (*glacier.InitiateJobOutput, error)
GlacierListJobs(vaultName string) (*glacier.ListJobsOutput, error)
GlacierGetJobOutput(vaultName, jobId string) (*glacier.GetJobOutputOutput, error)
GlacierDescribeJob(vaultName, jobId string) (*glacier.DescribeJobOutput, error)
GlacierInventoryRetrieval(vaultName string) (*glacier.InitiateJobOutput, error)
GlacierDownloadToMinio(vaultName, jobId, targetBucket, targetPath string) error
GlacierDownloadToLocal(vaultName, jobId, localPath string) error
S3PutObject(bucketName string, objectName string, fileBuffer io.Reader) (*manager.UploadOutput, error)
ListBuckets() ([]s3types.Bucket, error)
BucketExists(bucketName string) bool
DeleteObjects(bucketName string, objectKeys []string) error
IsConnected() bool
}
func NewAwsService ¶
func NewAwsService() AwsService
type CacheService ¶ added in v1.5.0
type CacheService interface {
Get(key string) ([]byte, error)
Set(key string, value []byte, expiration time.Duration) error
Delete(key string) error
GetResizedImage(bucket, path string, width, height uint) ([]byte, error)
SetResizedImage(bucket, path string, width, height uint, data []byte) error
FlushAll() error
Close() error
}
func NewCacheService ¶ added in v1.5.0
func NewCacheService() (CacheService, error)
type ImageService ¶ added in v1.5.0
func (*ImageService) GetImage ¶ added in v1.5.0
func (s *ImageService) GetImage(bucket, objectName string, width, height int) ([]byte, error)
GetImage gets an image from storage and optionally resizes it
func (*ImageService) GetImageInfo ¶ added in v1.5.0
func (s *ImageService) GetImageInfo(data []byte) (width uint, height uint, format string, err error)
GetImageInfo returns width, height and format of an image
func (*ImageService) ImagickFormat ¶ added in v1.5.0
func (s *ImageService) ImagickFormat(image []byte) (error, string)
func (*ImageService) ImagickGetWidthHeight ¶ added in v1.5.0
func (s *ImageService) ImagickGetWidthHeight(image []byte) (error, uint, uint)
func (*ImageService) ImagickResize ¶ added in v1.5.0
func (s *ImageService) ImagickResize(image []byte, targetWidth, targetHeight uint) []byte
func (*ImageService) IsImageFile ¶ added in v1.5.0
func (s *ImageService) IsImageFile(data []byte) bool
IsImageFile checks if the file is a valid image by examining its content (magic bytes)
func (*ImageService) IsResizable ¶ added in v1.5.0
func (s *ImageService) IsResizable(data []byte) bool
IsResizable checks if the file is a valid image that can be resized
func (*ImageService) ProcessImage ¶ added in v1.5.0
func (s *ImageService) ProcessImage(data []byte) ([]byte, error)
ProcessImage processes an image (resize, optimize, etc.)
func (*ImageService) ResizeImage ¶ added in v1.5.0
func (s *ImageService) ResizeImage(data []byte, width, height int) ([]byte, error)
ResizeImage resizes an image to the specified dimensions
type StatsService ¶ added in v1.5.0
type StatsService struct {
// contains filtered or unexported fields
}
func NewStatsService ¶ added in v1.5.0
func NewStatsService() *StatsService
func (*StatsService) AddUploadBytes ¶ added in v1.5.0
func (s *StatsService) AddUploadBytes(bytes int64)
func (*StatsService) DecrementActiveUploads ¶ added in v1.5.0
func (s *StatsService) DecrementActiveUploads()
func (*StatsService) GetActiveUploads ¶ added in v1.5.0
func (s *StatsService) GetActiveUploads() int
func (*StatsService) GetCPUUsage ¶ added in v1.5.0
func (s *StatsService) GetCPUUsage() float64
func (*StatsService) GetCacheHitRate ¶ added in v1.5.0
func (s *StatsService) GetCacheHitRate() float64
func (*StatsService) GetDiskUsage ¶ added in v1.5.0
func (s *StatsService) GetDiskUsage() map[string]int64
func (*StatsService) GetMemoryUsage ¶ added in v1.5.0
func (s *StatsService) GetMemoryUsage() float64
func (*StatsService) GetRecentErrors ¶ added in v1.5.0
func (s *StatsService) GetRecentErrors() []string
func (*StatsService) GetUploadSpeed ¶ added in v1.5.0
func (s *StatsService) GetUploadSpeed() float64
func (*StatsService) IncrementActiveUploads ¶ added in v1.5.0
func (s *StatsService) IncrementActiveUploads()
func (*StatsService) IncrementCacheHit ¶ added in v1.5.0
func (s *StatsService) IncrementCacheHit()
func (*StatsService) IncrementCacheMiss ¶ added in v1.5.0
func (s *StatsService) IncrementCacheMiss()
func (*StatsService) LogError ¶ added in v1.5.0
func (s *StatsService) LogError(err string)