upload

package
v2.13.0 Latest Latest
Warning

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

Go to latest
Published: May 2, 2023 License: Apache-2.0 Imports: 36 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Cleanup

func Cleanup(upload *Upload, failure bool, keepUpload bool)

Cleanup cleans the upload

func CreateNodeForUpload

func CreateNodeForUpload(upload *Upload, initAttrs node.Attributes) (*node.Node, error)

CreateNodeForUpload will create the target node for the Upload

Types

type PermissionsChecker

type PermissionsChecker interface {
	AssemblePermissions(ctx context.Context, n *node.Node) (ap provider.ResourcePermissions, err error)
}

PermissionsChecker defines an interface for checking permissions on a Node

type Tree

type Tree interface {
	Setup() error

	GetMD(ctx context.Context, node *node.Node) (os.FileInfo, error)
	ListFolder(ctx context.Context, node *node.Node) ([]*node.Node, error)
	// CreateHome(owner *userpb.UserId) (n *node.Node, err error)
	CreateDir(ctx context.Context, node *node.Node) (err error)
	// CreateReference(ctx context.Context, node *node.Node, targetURI *url.URL) error
	Move(ctx context.Context, oldNode *node.Node, newNode *node.Node) (err error)
	Delete(ctx context.Context, node *node.Node) (err error)
	RestoreRecycleItemFunc(ctx context.Context, spaceid, key, trashPath string, target *node.Node) (*node.Node, *node.Node, func() error, error)
	PurgeRecycleItemFunc(ctx context.Context, spaceid, key, purgePath string) (*node.Node, func() error, error)

	WriteBlob(node *node.Node, binPath string) error
	ReadBlob(node *node.Node) (io.ReadCloser, error)
	DeleteBlob(node *node.Node) error

	Propagate(ctx context.Context, node *node.Node, sizeDiff int64) (err error)
}

Tree is used to manage a tree hierarchy

type Upload

type Upload struct {
	// we use a struct field on the upload as tus pkg will give us an empty context.Background
	Ctx context.Context
	// info stores the current information about the upload
	Info tusd.FileInfo
	// node for easy access
	Node *node.Node
	// contains filtered or unexported fields
}

Upload processes the upload it implements tus tusd.Upload interface https://tus.io/protocols/resumable-upload.html#core-protocol it also implements its termination extension as specified in https://tus.io/protocols/resumable-upload.html#termination it also implements its creation-defer-length extension as specified in https://tus.io/protocols/resumable-upload.html#creation it also implements its concatenation extension as specified in https://tus.io/protocols/resumable-upload.html#concatenation

func Get

func Get(ctx context.Context, id string, lu *lookup.Lookup, tp Tree, fsRoot string, pub events.Publisher, async bool, tknopts options.TokenOptions) (*Upload, error)

Get returns the Upload for the given upload id

func New

func New(ctx context.Context, info tusd.FileInfo, lu *lookup.Lookup, tp Tree, p PermissionsChecker, fsRoot string, pub events.Publisher, async bool, tknopts options.TokenOptions) (upload *Upload, err error)

New returns a new processing instance

func (*Upload) ConcatUploads

func (upload *Upload) ConcatUploads(_ context.Context, uploads []tusd.Upload) (err error)

ConcatUploads concatenates multiple uploads

func (*Upload) DeclareLength

func (upload *Upload) DeclareLength(_ context.Context, length int64) error

DeclareLength updates the upload length information

func (*Upload) Finalize

func (upload *Upload) Finalize() (err error)

Finalize finalizes the upload (eg moves the file to the internal destination)

func (*Upload) FinishUpload

func (upload *Upload) FinishUpload(_ context.Context) error

FinishUpload finishes an upload and moves the file to the internal destination

func (*Upload) GetInfo

func (upload *Upload) GetInfo(_ context.Context) (tusd.FileInfo, error)

GetInfo returns the FileInfo

func (*Upload) GetReader

func (upload *Upload) GetReader(_ context.Context) (io.Reader, error)

GetReader returns an io.Reader for the upload

func (*Upload) Terminate

func (upload *Upload) Terminate(_ context.Context) error

Terminate terminates the upload

func (*Upload) URL

func (upload *Upload) URL(_ context.Context) (string, error)

URL returns a url to download an upload

func (*Upload) WriteChunk

func (upload *Upload) WriteChunk(_ context.Context, offset int64, src io.Reader) (int64, error)

WriteChunk writes the stream from the reader to the given offset of the upload

Jump to

Keyboard shortcuts

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