file

package
v0.40.0 Latest Latest
Warning

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

Go to latest
Published: May 9, 2021 License: MIT Imports: 13 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 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 a 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(storage Storage) *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)

func (*Service) WitHashPartSize

func (m *Service) WitHashPartSize(hashPartSize int) *Service

WitHashPartSize sets size of part to use in tg.FileHash. Must be valid part size.

func (*Service) WitHashRangeSize

func (m *Service) WitHashRangeSize(hashRangeSize int) *Service

WitHashRangeSize sets size of range to return in upload.getFileHashes.

type Storage

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

Storage is a abstraction for Telegram file storage.

Jump to

Keyboard shortcuts

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