Documentation ¶
Index ¶
- type OcisSession
- func (s *OcisSession) Chunk() string
- func (session *OcisSession) Cleanup(revertNodeMetadata, cleanBin, cleanInfo bool)
- func (session *OcisSession) ConcatUploads(_ context.Context, uploads []tusd.Upload) (err error)
- func (s *OcisSession) Context(ctx context.Context) context.Context
- func (session *OcisSession) DeclareLength(ctx context.Context, length int64) error
- func (s *OcisSession) Dir() string
- func (s *OcisSession) Executant() userpb.UserId
- func (s *OcisSession) Expires() time.Time
- func (s *OcisSession) Filename() string
- func (session *OcisSession) Finalize() (err error)
- func (session *OcisSession) FinishUpload(ctx context.Context) error
- func (session *OcisSession) GetInfo(_ context.Context) (tusd.FileInfo, error)
- func (session *OcisSession) GetReader(ctx context.Context) (io.ReadCloser, error)
- func (s *OcisSession) HeaderIfMatch() string
- func (s *OcisSession) HeaderIfNoneMatch() string
- func (s *OcisSession) HeaderIfUnmodifiedSince() string
- func (s *OcisSession) ID() string
- func (s *OcisSession) InitiatorID() string
- func (s *OcisSession) IsProcessing() bool
- func (s *OcisSession) MTime() time.Time
- func (s *OcisSession) Node(ctx context.Context) (*node.Node, error)
- func (s *OcisSession) NodeExists() bool
- func (s *OcisSession) NodeID() string
- func (s *OcisSession) NodeParentID() string
- func (s *OcisSession) Offset() int64
- func (s *OcisSession) Persist(ctx context.Context) error
- func (s *OcisSession) ProviderID() string
- func (s *OcisSession) Purge(ctx context.Context) error
- func (s *OcisSession) Reference() provider.Reference
- func (s *OcisSession) ScanData() (string, time.Time)
- func (s *OcisSession) SetExecutant(u *userpb.User)
- func (s *OcisSession) SetMetadata(key, value string)
- func (s *OcisSession) SetScanData(result string, date time.Time)
- func (s *OcisSession) SetSize(size int64)
- func (s *OcisSession) SetSizeIsDeferred(value bool)
- func (s *OcisSession) SetStorageValue(key, value string)
- func (s *OcisSession) Size() int64
- func (s *OcisSession) SizeDiff() int64
- func (s *OcisSession) SpaceID() string
- func (s *OcisSession) SpaceOwner() *userpb.UserId
- func (session *OcisSession) Terminate(_ context.Context) error
- func (s *OcisSession) ToFileInfo() tusd.FileInfo
- func (s *OcisSession) TouchBin() error
- func (session *OcisSession) URL(_ context.Context) (string, error)
- func (session *OcisSession) WriteChunk(ctx context.Context, offset int64, src io.Reader) (int64, error)
- type OcisStore
- func (store OcisStore) Cleanup(ctx context.Context, session Session, ...)
- func (store OcisStore) CreateNodeForUpload(session *OcisSession, initAttrs node.Attributes) (*node.Node, error)
- func (store OcisStore) Get(ctx context.Context, id string) (*OcisSession, error)
- func (store OcisStore) List(ctx context.Context) ([]*OcisSession, error)
- func (store OcisStore) New(ctx context.Context) *OcisSession
- type PermissionsChecker
- type Session
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
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) 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) 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?
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