upload

package
v2.24.1 Latest Latest
Warning

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

Go to latest
Published: Sep 11, 2024 License: Apache-2.0 Imports: 36 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type OcisSession added in v2.18.0

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

OcisSession extends tus upload lifecycle with postprocessing steps.

func (*OcisSession) Chunk added in v2.18.0

func (s *OcisSession) Chunk() string

Chunk returns the chunk name when a legacy chunked upload was started

func (*OcisSession) Cleanup added in v2.18.0

func (session *OcisSession) Cleanup(revertNodeMetadata, cleanBin, cleanInfo bool)

cleanup cleans up after the upload is finished

func (*OcisSession) ConcatUploads added in v2.18.0

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

ConcatUploads concatenates multiple uploads

func (*OcisSession) Context added in v2.18.0

func (s *OcisSession) Context(ctx context.Context) context.Context

Context returns a context with the user, logger and lockid used when initiating the upload session

func (*OcisSession) DeclareLength added in v2.18.0

func (session *OcisSession) DeclareLength(ctx context.Context, length int64) error

DeclareLength updates the upload length information

func (*OcisSession) Dir added in v2.18.0

func (s *OcisSession) Dir() string

Dir returns the directory to which the upload is made TODO get rid of Dir(), whoever consumes the reference should be able to deal with a relative reference. Dir is only used to:

  • fill the Path property when emitting the UploadReady event after postprocessing finished. I wonder why the UploadReady contains a finished flag ... maybe multiple distinct events would make more sense.
  • build the reference that is passed to the FileUploaded event in the UploadFinishedFunc callback passed to the Upload call used for simple datatx put requests

AFAICT only search and audit services consume the path.

  • search needs to index from the root anyway. And it only needs the most recent path to put it in the index. So it should already be able to deal with an id based reference.
  • audit on the other hand needs to log events with the path at the state of the event ... so it does need the full path.

I think we can safely determine the path later, right before emitting the event. And maybe make it configurable, because only audit needs it, anyway.

func (*OcisSession) Executant added in v2.18.0

func (s *OcisSession) Executant() userpb.UserId

Executant returns the id of the user that initiated the upload session

func (*OcisSession) Expires added in v2.18.0

func (s *OcisSession) Expires() time.Time

Expires returns the time the upload session expires

func (*OcisSession) Filename added in v2.18.0

func (s *OcisSession) Filename() string

Filename returns the name of the node which is not the same as the name af the file being uploaded for legacy chunked uploads

func (*OcisSession) Finalize added in v2.18.0

func (session *OcisSession) Finalize() (err error)

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

func (*OcisSession) FinishUpload added in v2.18.0

func (session *OcisSession) FinishUpload(ctx context.Context) error

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

func (*OcisSession) GetInfo added in v2.18.0

func (session *OcisSession) GetInfo(_ context.Context) (tusd.FileInfo, error)

GetInfo returns the FileInfo

func (*OcisSession) GetReader added in v2.18.0

func (session *OcisSession) GetReader(ctx context.Context) (io.ReadCloser, error)

GetReader returns an io.Reader for the upload

func (*OcisSession) HeaderIfMatch added in v2.18.0

func (s *OcisSession) HeaderIfMatch() string

HeaderIfMatch returns the if-match header for the upload session

func (*OcisSession) HeaderIfNoneMatch added in v2.18.0

func (s *OcisSession) HeaderIfNoneMatch() string

HeaderIfNoneMatch returns the if-none-match header for the upload session

func (*OcisSession) HeaderIfUnmodifiedSince added in v2.18.0

func (s *OcisSession) HeaderIfUnmodifiedSince() string

HeaderIfUnmodifiedSince returns the if-unmodified-since header for the upload session

func (*OcisSession) ID added in v2.18.0

func (s *OcisSession) ID() string

ID returns the upload session id

func (*OcisSession) InitiatorID added in v2.19.6

func (s *OcisSession) InitiatorID() string

InitiatorID returns the id of the initiating client

func (*OcisSession) IsProcessing added in v2.18.0

func (s *OcisSession) IsProcessing() bool

IsProcessing returns true if all bytes have been received. The session then has entered postprocessing state.

func (*OcisSession) MTime added in v2.18.0

func (s *OcisSession) MTime() time.Time

MTime returns the mtime to use for the uploaded file

func (*OcisSession) Node added in v2.18.0

func (s *OcisSession) Node(ctx context.Context) (*node.Node, error)

Node returns the node for the session

func (*OcisSession) NodeExists added in v2.18.0

func (s *OcisSession) NodeExists() bool

NodeExists returns wether or not the node existed during InitiateUpload. FIXME If two requests try to write the same file they both will store a new random node id in the session and try to initialize a new node when finishing the upload. The second request will fail with an already exists error when trying to create the symlink for the node in the parent directory. A node should be created as part of InitiateUpload. When listing a directory we can decide if we want to skip the entry, or expose uploed progress information. But that is a bigger change and might involve client work.

func (*OcisSession) NodeID added in v2.18.0

func (s *OcisSession) NodeID() string

NodeID returns the node id

func (*OcisSession) NodeParentID added in v2.18.0

func (s *OcisSession) NodeParentID() string

NodeParentID returns the nodes parent id

func (*OcisSession) Offset added in v2.18.0

func (s *OcisSession) Offset() int64

Offset returns the current upload offset

func (*OcisSession) Persist added in v2.18.0

func (s *OcisSession) Persist(ctx context.Context) error

Persist writes the upload session metadata to disk

func (*OcisSession) ProviderID added in v2.18.0

func (s *OcisSession) ProviderID() string

ProviderID returns the provider id

func (*OcisSession) Purge added in v2.18.0

func (s *OcisSession) Purge(ctx context.Context) error

Purge deletes the upload session metadata and written binary data

func (*OcisSession) Reference added in v2.18.0

func (s *OcisSession) Reference() provider.Reference

Reference returns a reference that can be used to access the uploaded resource

func (*OcisSession) ScanData added in v2.19.6

func (s *OcisSession) ScanData() (string, time.Time)

ScanData returns the virus scan data

func (*OcisSession) SetExecutant added in v2.18.0

func (s *OcisSession) SetExecutant(u *userpb.User)

SetExecutant is used to remember the user that initiated the upload session

func (*OcisSession) SetMetadata added in v2.18.0

func (s *OcisSession) SetMetadata(key, value string)

SetMetadata is used to fill the upload metadata that will be exposed to the end user

func (*OcisSession) SetScanData added in v2.19.6

func (s *OcisSession) SetScanData(result string, date time.Time)

SetScanData sets virus scan data to the upload session

func (*OcisSession) SetSize added in v2.18.0

func (s *OcisSession) SetSize(size int64)

SetSize will set the upload size of the underlying tus info.

func (*OcisSession) SetSizeIsDeferred added in v2.18.0

func (s *OcisSession) SetSizeIsDeferred(value bool)

SetSizeIsDeferred is uset to change the SizeIsDeferred property of the underlying tus info.

func (*OcisSession) SetStorageValue added in v2.18.0

func (s *OcisSession) SetStorageValue(key, value string)

SetStorageValue is used to set metadata only relevant for the upload session implementation

func (*OcisSession) Size added in v2.18.0

func (s *OcisSession) Size() int64

Size returns the upload size

func (*OcisSession) SizeDiff added in v2.18.0

func (s *OcisSession) SizeDiff() int64

SizeDiff returns the size diff that was calculated after postprocessing

func (*OcisSession) SpaceID added in v2.18.0

func (s *OcisSession) SpaceID() string

SpaceID returns the space id

func (*OcisSession) SpaceOwner added in v2.18.0

func (s *OcisSession) SpaceOwner() *userpb.UserId

SpaceOwner returns the id of the space owner

func (*OcisSession) Terminate added in v2.18.0

func (session *OcisSession) Terminate(_ context.Context) error

Terminate terminates the upload

func (*OcisSession) ToFileInfo added in v2.18.0

func (s *OcisSession) ToFileInfo() tusd.FileInfo

ToFileInfo returns tus compatible FileInfo so the tus handler can access the upload offset

func (*OcisSession) TouchBin added in v2.18.0

func (s *OcisSession) TouchBin() error

TouchBin creates a file to contain the binary data. It's size will be used to keep track of the tus upload offset.

func (*OcisSession) URL added in v2.18.0

func (session *OcisSession) URL(_ context.Context) (string, error)

URL returns a url to download an upload

func (*OcisSession) WriteChunk added in v2.18.0

func (session *OcisSession) WriteChunk(ctx context.Context, offset int64, src io.Reader) (int64, error)

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

type OcisStore added in v2.18.0

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

OcisStore manages upload sessions

func NewSessionStore added in v2.18.0

func NewSessionStore(fs storage.FS, aspects aspects.Aspects, root string, async bool, tknopts options.TokenOptions) *OcisStore

NewSessionStore returns a new OcisStore

func (OcisStore) Cleanup added in v2.18.0

func (store OcisStore) Cleanup(ctx context.Context, session Session, revertNodeMetadata, keepUpload, unmarkPostprocessing bool)

Cleanup cleans upload metadata, binary data and processing status as necessary

func (OcisStore) CreateNodeForUpload added in v2.18.0

func (store OcisStore) CreateNodeForUpload(session *OcisSession, initAttrs node.Attributes) (*node.Node, error)

CreateNodeForUpload will create the target node for the Upload TODO move this to the node package as NodeFromUpload? should we in InitiateUpload create the node first? and then the upload?

func (OcisStore) Get added in v2.18.0

func (store OcisStore) Get(ctx context.Context, id string) (*OcisSession, error)

Get returns the upload session for the given upload id

func (OcisStore) List added in v2.18.0

func (store OcisStore) List(ctx context.Context) ([]*OcisSession, error)

List lists all upload sessions

func (OcisStore) New added in v2.18.0

func (store OcisStore) New(ctx context.Context) *OcisSession

New returns a new upload session

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 Session added in v2.18.0

type Session interface {
	ID() string
	Node(ctx context.Context) (*node.Node, error)
	Context(ctx context.Context) context.Context
	Cleanup(revertNodeMetadata, cleanBin, cleanInfo bool)
}

Session is the interface used by the Cleanup call

Jump to

Keyboard shortcuts

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