cachefs

package
v0.0.0-...-e41513e Latest Latest
Warning

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

Go to latest
Published: Jul 10, 2020 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DoUploadedPhotoFile

func DoUploadedPhotoFile(src *PhotoFile, extName string, srcData []byte, isABC bool, cb func(pi *PhotoInfo)) error

TODO(@benqi):

	我们未来的图片存储系统可能会按facebook的Haystack论文来实现
	mtproto协议也定义了一套自己的文件存储方案,fileLocation#53d69076 dc_id:int volume_id:long local_id:int secret:long = FileLocation;
	在这里,我们重新定义mtproto的volume_id和local_id,对应Haystack的key和alternate_key,secret对应cookie
 在当前简单实现里,volume_id由sonwflake生成,local_id对应于图片类型,secret为access_hash

TODO(@benqi):

参数使用mtproto.File

func InitCacheFS

func InitCacheFS(dataPath string) error

func NewCacheFile

func NewCacheFile(creatorId, fileId int64) *cacheFile

func ReadFileOffsetData

func ReadFileOffsetData(filePath string, offset int32, limit int32) ([]byte, error)

Types

type DocumentFile

type DocumentFile struct {
	*os.File
	// contains filtered or unexported fields
}

func CreateDocumentFile

func CreateDocumentFile(fileId, accessHash int64) (d *DocumentFile, err error)

func NewDocumentFile

func NewDocumentFile(fileId, accessHash int64) *DocumentFile

func (*DocumentFile) Close

func (f *DocumentFile) Close()

func (*DocumentFile) ReadData

func (f *DocumentFile) ReadData(offset int32, limit int32) ([]byte, error)

func (*DocumentFile) Sync

func (f *DocumentFile) Sync()

func (*DocumentFile) ToFilePath

func (f *DocumentFile) ToFilePath() string

func (*DocumentFile) ToFilePath2

func (f *DocumentFile) ToFilePath2() string

func (*DocumentFile) Write

func (f *DocumentFile) Write(b []byte) (int, error)

type PhotoFile

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

func NewPhotoFile

func NewPhotoFile(volumeId int64, localId int32, secretId int64) *PhotoFile

func (*PhotoFile) ReadData

func (f *PhotoFile) ReadData(offset int32, limit int32) ([]byte, error)

func (*PhotoFile) ToFilePath

func (f *PhotoFile) ToFilePath() string

func (*PhotoFile) ToFilePath2

func (f *PhotoFile) ToFilePath2() string

func (*PhotoFile) WritePhotoFile

func (f *PhotoFile) WritePhotoFile(b []byte) error

type PhotoInfo

type PhotoInfo struct {
	LocalId  int32
	Width    int32
	Height   int32
	FileSize int64
}

Jump to

Keyboard shortcuts

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