stream

package
v3.35.3-8Mi Latest Latest
Warning

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

Go to latest
Published: Jul 3, 2024 License: AGPL-3.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

View Source
const InMemoryBufMaxSize = 10 // Megabytes
View Source
const InMemoryBufMaxSizeBytes = InMemoryBufMaxSize * 1024 * 1024

Variables

This section is empty.

Functions

func GetRangeReadCloserFromLink(size int64, link *model.Link) (model.RangeReadCloserIF, error)

func RequestRangedHttp

func RequestRangedHttp(ctx context.Context, link *model.Link, offset, length int64) (*http.Response, error)

Types

type FileStream

type FileStream struct {
	Ctx context.Context
	model.Obj
	io.Reader
	Mimetype          string
	WebPutAsTask      bool
	ForceStreamUpload bool
	Exist             model.Obj //the file existed in the destination, we can reuse some info since we wil overwrite it
	utils.Closers
	// contains filtered or unexported fields
}

func (*FileStream) CacheFullInTempFile

func (f *FileStream) CacheFullInTempFile() (model.File, error)

CacheFullInTempFile save all data into tmpFile. Not recommended since it wears disk, and can't start upload until the file is written. It's not thread-safe!

func (*FileStream) Close

func (f *FileStream) Close() error

func (*FileStream) GetExist

func (f *FileStream) GetExist() model.Obj

func (*FileStream) GetMimetype

func (f *FileStream) GetMimetype() string

func (*FileStream) GetSize

func (f *FileStream) GetSize() int64

func (*FileStream) IsForceStreamUpload

func (f *FileStream) IsForceStreamUpload() bool

func (*FileStream) NeedStore

func (f *FileStream) NeedStore() bool

func (*FileStream) RangeRead

func (f *FileStream) RangeRead(httpRange http_range.Range) (io.Reader, error)

RangeRead have to cache all data first since only Reader is provided. also support a peeking RangeRead at very start, but won't buffer more than 10MB data in memory

func (*FileStream) SetExist

func (f *FileStream) SetExist(obj model.Obj)

func (*FileStream) SetTmpFile

func (f *FileStream) SetTmpFile(r *os.File)

type SeekableStream

type SeekableStream struct {
	FileStream
	Link *model.Link
	// contains filtered or unexported fields
}

for most internal stream, which is either RangeReadCloser or MFile

func NewSeekableStream

func NewSeekableStream(fs FileStream, link *model.Link) (*SeekableStream, error)

func (*SeekableStream) CacheFullInTempFile

func (ss *SeekableStream) CacheFullInTempFile() (model.File, error)

func (*SeekableStream) RangeRead

func (ss *SeekableStream) RangeRead(httpRange http_range.Range) (io.Reader, error)

RangeRead is not thread-safe, pls use it in single thread only.

func (*SeekableStream) Read

func (ss *SeekableStream) Read(p []byte) (n int, err error)

only provide Reader as full stream when it's demanded. in rapid-upload, we can skip this to save memory

Jump to

Keyboard shortcuts

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