Documentation
¶
Index ¶
- Constants
- Variables
- func AttachmentOriginalKey(channelID, attachmentID int64) string
- func AttachmentPreviewKey(channelID, attachmentID int64) string
- func AvatarKey(userID, avatarID int64) string
- func DecodeImageDimensions(data []byte) (int64, int64, error)
- func DetectAnimated(data []byte) (bool, error)
- func EmojiMasterKey(emojiID int64) string
- func EmojiSizedKey(emojiID int64, size int) string
- func EmojiVariantKey(emojiID int64, variant string) string
- func IconKey(guildID, iconID int64) string
- func InferAttachmentKind(contentType, name string) string
- func PublicURL(base, key string) string
- func Retry(ctx context.Context, attempts int, delay time.Duration, ...) error
- type AttachmentResult
- type AttachmentService
- type AvatarResult
- type AvatarService
- type BufferedBody
- type EmojiResult
- type EmojiService
- type FFmpegProcessor
- func (p *FFmpegProcessor) ConvertToWebP(ctx context.Context, source io.Reader, maxDimension int, sizeLimit int64) ([]byte, error)
- func (p *FFmpegProcessor) CreateWebPPreview(ctx context.Context, source string, maxDimension int) ([]byte, error)
- func (p *FFmpegProcessor) ProbeDimensions(ctx context.Context, source string) (int64, int64, error)
- func (p *FFmpegProcessor) ProcessEmoji(ctx context.Context, source []byte, sourceWidth, sourceHeight int64, ...) (*ProcessedEmoji, error)
- type IconResult
- type IconService
- type MediaProcessor
- type PreparedBody
- type ProcessedEmoji
- type Storage
Constants ¶
View Source
const (
DefaultAttachmentPreviewSize = 350
)
Variables ¶
View Source
var ( ErrPlaceholderNotFound = errors.New("upload placeholder not found") ErrForbidden = errors.New("upload forbidden") ErrAlreadyDone = errors.New("upload already completed") ErrEmptyBody = errors.New("upload body is empty") ErrSizeMismatch = errors.New("upload size mismatch") ErrTooLarge = errors.New("upload body exceeds declared size") ErrUnsupportedMedia = errors.New("unsupported media type") ErrInvalidDimensions = errors.New("image dimensions exceed limits") ErrQuotaExceeded = errors.New("emoji quota exceeded") ErrUploadExpired = errors.New("upload placeholder expired") ErrMediaProcess = errors.New("media processing failed") ErrStorage = errors.New("storage operation failed") ErrFinalize = errors.New("finalize operation failed") )
Functions ¶
func AttachmentOriginalKey ¶
func AttachmentPreviewKey ¶
func DetectAnimated ¶
func EmojiMasterKey ¶
func EmojiSizedKey ¶
func EmojiVariantKey ¶
func InferAttachmentKind ¶
Types ¶
type AttachmentResult ¶
type AttachmentService ¶
type AttachmentService struct {
// contains filtered or unexported fields
}
func NewAttachmentService ¶
func NewAttachmentService(repo attachmentrepo.Attachment, storage Storage, publicBase string, processor MediaProcessor) *AttachmentService
func (*AttachmentService) Upload ¶
func (s *AttachmentService) Upload(ctx context.Context, actorID, channelID, attachmentID int64, body io.Reader) (_ *AttachmentResult, err error)
type AvatarResult ¶
type AvatarService ¶
type AvatarService struct {
// contains filtered or unexported fields
}
func NewAvatarService ¶
func NewAvatarService(repo avatarrepo.Avatar, storage Storage, publicBase string, processor MediaProcessor, maxDim int, maxFileSize int64) *AvatarService
func (*AvatarService) Upload ¶
func (s *AvatarService) Upload(ctx context.Context, actorID, userID, avatarID int64, body io.Reader) (_ *AvatarResult, err error)
type BufferedBody ¶
func ReadBodyToMemory ¶
func ReadBodyToMemory(reader io.Reader, expectedSize int64) (*BufferedBody, error)
type EmojiResult ¶
type EmojiService ¶
type EmojiService struct {
// contains filtered or unexported fields
}
func NewEmojiService ¶
func NewEmojiService(repo emojirepo.Emoji, storage Storage, publicBase string, processor *FFmpegProcessor) *EmojiService
func (*EmojiService) Upload ¶
func (s *EmojiService) Upload(ctx context.Context, guildID, emojiID int64, body io.Reader) (_ *EmojiResult, err error)
type FFmpegProcessor ¶
type FFmpegProcessor struct {
// contains filtered or unexported fields
}
func NewFFmpegProcessor ¶
func NewFFmpegProcessor() *FFmpegProcessor
func (*FFmpegProcessor) ConvertToWebP ¶
func (*FFmpegProcessor) CreateWebPPreview ¶
func (*FFmpegProcessor) ProbeDimensions ¶
func (*FFmpegProcessor) ProcessEmoji ¶
func (p *FFmpegProcessor) ProcessEmoji(ctx context.Context, source []byte, sourceWidth, sourceHeight int64, sizeLimit int64) (*ProcessedEmoji, error)
type IconResult ¶
type IconService ¶
type IconService struct {
// contains filtered or unexported fields
}
func NewIconService ¶
func NewIconService(repo iconrepo.Icon, storage Storage, publicBase string, processor MediaProcessor, maxDim int, maxFileSize int64) *IconService
func (*IconService) Upload ¶
func (s *IconService) Upload(ctx context.Context, guildID, iconID int64, body io.Reader) (_ *IconResult, err error)
type MediaProcessor ¶
type PreparedBody ¶
func PrepareBody ¶
func PrepareBody(reader io.Reader, expectedSize int64) (*PreparedBody, error)
type ProcessedEmoji ¶
Click to show internal directories.
Click to hide internal directories.