file

package
v0.113.0 Latest Latest
Warning

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

Go to latest
Published: Nov 28, 2024 License: MIT Imports: 14 Imported by: 0

Documentation

Overview

Package file contains file service implementation for tgtest server.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config added in v0.50.0

type Config struct {
	// Storage to store files.
	// InMemory will be used.
	Storage Storage
	// HashPartSize is a size of part to use in tg.FileHash.
	HashPartSize int
	// HashRangeSize is size of range to return in upload.getFileHashes.
	HashRangeSize int
}

type File

type File interface {
	io.ReaderAt
	io.WriterAt
	io.Closer
	PartSize() int
	SetPartSize(v int)
	Size() int
}

File represents Telegram file.

type InMemory

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

InMemory is an inmemory implementation of file storage.

func NewInMemory

func NewInMemory() *InMemory

NewInMemory creates new InMemory.

func (*InMemory) Open

func (i *InMemory) Open(name string) (File, error)

Open implement Storage.

type Service

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

Service is a Telegram file service.

func NewService

func NewService(cfg Config) *Service

NewService creates new file Service.

func (*Service) OnMessage

func (m *Service) OnMessage(server *tgtest.Server, req *tgtest.Request) error

OnMessage implements tgtest.Handler.

func (*Service) Register

func (m *Service) Register(dispatcher *tgtest.Dispatcher)

Register registers service handlers.

func (*Service) UploadGetFile

func (m *Service) UploadGetFile(ctx context.Context, request *tg.UploadGetFileRequest) (tg.UploadFileClass, error)

func (*Service) UploadGetFileHashes

func (m *Service) UploadGetFileHashes(
	ctx context.Context,
	request *tg.UploadGetFileHashesRequest,
) ([]tg.FileHash, error)

func (*Service) UploadSaveBigFilePart

func (m *Service) UploadSaveBigFilePart(ctx context.Context, request *tg.UploadSaveBigFilePartRequest) (bool, error)

func (*Service) UploadSaveFilePart

func (m *Service) UploadSaveFilePart(ctx context.Context, request *tg.UploadSaveFilePartRequest) (bool, error)

type Storage

type Storage interface {
	Open(name string) (File, error)
}

Storage is an abstraction for Telegram file storage.

Jump to

Keyboard shortcuts

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