Documentation
¶
Index ¶
- Constants
- Variables
- func ContentType(file store.MediaFile) string
- func Convertible(mediaType string) bool
- func DownloadName(file store.MediaFile) string
- func Handler(deps HandlerDeps) http.Handler
- func UploadHandler(deps UploadHandlerDeps) http.Handler
- type Clients
- type Downloader
- type DownloaderDeps
- type ExpiredUploadError
- type FFmpeg
- type FetchConfig
- type FetchError
- type File
- type Files
- func (f *Files) AccountBytes(accountID int64) (int64, error)
- func (f *Files) Close() error
- func (f *Files) Keep(accountID int64, content io.Reader) (string, error)
- func (f *Files) Open(name string) (*os.File, error)
- func (f *Files) Remove(name string) error
- func (f *Files) RemoveAccount(accountID int64) error
- type HandlerDeps
- type Links
- type Outbox
- func (o *Outbox) Load(ctx context.Context, grantID int64, src Source) (File, error)
- func (o *Outbox) Prepare(ctx context.Context, file File, voiceNote bool) (Ready, error)
- func (o *Outbox) Run(ctx context.Context) error
- func (o *Outbox) SaveUpload(grantID int64, declaredType string, body io.Reader) (Upload, error)
- func (o *Outbox) Scratch() (*os.File, func(), error)
- type OutboxDeps
- type Ready
- type Source
- type Transcoder
- type Upload
- type UploadHandlerDeps
Constants ¶
View Source
const ( MaxConcurrentDownloads = 4 MaxAttempts = 12 )
View Source
const ( LinkPath = "/media/" LinkLifetime = 15 * time.Minute )
View Source
const ( KindImage = "image" KindVideo = "video" KindAudio = "audio" KindDocument = "document" )
View Source
const ( MaxFileBytes = 100 << 20 UploadTTL = time.Hour UploadsDir = "uploads" TempDir = "tmp" )
View Source
const LinkRoute = "GET " + LinkPath + "{token}"
View Source
const (
MaxBase64Bytes = 5 << 20
)
View Source
const UploadsPath = "/uploads"
View Source
const VoiceNoteMime = "audio/ogg; codecs=opus"
Variables ¶
View Source
var ( ErrNotDownloaded = errors.New("the file is not downloaded yet") ErrStillRunning = errors.New("the download is still running") )
View Source
var ( ErrTooLarge = fmt.Errorf("the file is larger than %d MB", MaxFileBytes>>20) ErrEmpty = errors.New("the file is empty") ErrUnknownUpload = errors.New("unknown upload") )
View Source
var ( ErrOneSource = errors.New("pass exactly one of media_url, upload_id or base64") ErrBase64TooLarge = fmt.Errorf("the base64 file is larger than %d MB; POST it to /uploads and pass the upload_id", MaxBase64Bytes>>20) ErrInvalidBase64 = errors.New("the base64 value is not valid base64") )
Functions ¶
func ContentType ¶
func Convertible ¶
func DownloadName ¶
func Handler ¶
func Handler(deps HandlerDeps) http.Handler
func UploadHandler ¶
func UploadHandler(deps UploadHandlerDeps) http.Handler
Types ¶
type Downloader ¶
type Downloader struct {
// contains filtered or unexported fields
}
func NewDownloader ¶
func NewDownloader(deps DownloaderDeps) *Downloader
func (*Downloader) Notice ¶
func (d *Downloader) Notice(accountID int64, evt any)
func (*Downloader) Wake ¶
func (d *Downloader) Wake()
type DownloaderDeps ¶
type ExpiredUploadError ¶
func (*ExpiredUploadError) Error ¶
func (e *ExpiredUploadError) Error() string
type FetchError ¶
type FetchError struct {
Message string
}
func (*FetchError) Error ¶
func (e *FetchError) Error() string
type File ¶
type Files ¶
type Files struct {
// contains filtered or unexported fields
}
func (*Files) RemoveAccount ¶
type HandlerDeps ¶
type Outbox ¶
type Outbox struct {
// contains filtered or unexported fields
}
func NewOutbox ¶
func NewOutbox(deps OutboxDeps) (*Outbox, error)
func (*Outbox) SaveUpload ¶
type OutboxDeps ¶
type OutboxDeps struct {
DataDir string
Clock clock.Clock
Transcoder Transcoder
Fetch FetchConfig
Log *slog.Logger
}
type Ready ¶
type Transcoder ¶
Click to show internal directories.
Click to hide internal directories.