Documentation
¶
Index ¶
- Variables
- 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(ctx context.Context) (err error)
- func (session *OcisSession) FinishUpload(ctx context.Context) error
- func (session *OcisSession) FinishUploadDecomposed(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(ctx context.Context, 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 ¶
var (
ErrAlreadyExists = tusd.NewError("ERR_ALREADY_EXISTS", "file already exists", http.StatusConflict)
)
Functions ¶
This section is empty.
Types ¶
type OcisSession ¶
type OcisSession struct {
// contains filtered or unexported fields
}
OcisSession extends tus upload lifecycle with postprocessing steps.
func (*OcisSession) Chunk ¶
func (s *OcisSession) Chunk() string
Chunk returns the chunk name when a legacy chunked upload was started
func (*OcisSession) Cleanup ¶
func (session *OcisSession) Cleanup(revertNodeMetadata, cleanBin, cleanInfo bool)
cleanup cleans up after the upload is finished
func (*OcisSession) ConcatUploads ¶
ConcatUploads concatenates multiple uploads
func (*OcisSession) Context ¶
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 ¶
func (session *OcisSession) DeclareLength(ctx context.Context, length int64) error
DeclareLength updates the upload length information
func (*OcisSession) Dir ¶
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 ¶
func (s *OcisSession) Executant() userpb.UserId
Executant returns the id of the user that initiated the upload session
func (*OcisSession) Expires ¶
func (s *OcisSession) Expires() time.Time
Expires returns the time the upload session expires
func (*OcisSession) Filename ¶
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 ¶
func (session *OcisSession) Finalize(ctx context.Context) (err error)
Finalize finalizes the upload (eg moves the file to the internal destination)
func (*OcisSession) FinishUpload ¶
func (session *OcisSession) FinishUpload(ctx context.Context) error
FinishUpload finishes an upload and moves the file to the internal destination implements tusd.DataStore interface returns tusd errors
func (*OcisSession) FinishUploadDecomposed ¶
func (session *OcisSession) FinishUploadDecomposed(ctx context.Context) error
FinishUploadDecomposed finishes an upload and moves the file to the internal destination retures errtypes errors
func (*OcisSession) GetReader ¶
func (session *OcisSession) GetReader(ctx context.Context) (io.ReadCloser, error)
GetReader returns an io.Reader for the upload
func (*OcisSession) HeaderIfMatch ¶
func (s *OcisSession) HeaderIfMatch() string
HeaderIfMatch returns the if-match header for the upload session
func (*OcisSession) HeaderIfNoneMatch ¶
func (s *OcisSession) HeaderIfNoneMatch() string
HeaderIfNoneMatch returns the if-none-match header for the upload session
func (*OcisSession) HeaderIfUnmodifiedSince ¶
func (s *OcisSession) HeaderIfUnmodifiedSince() string
HeaderIfUnmodifiedSince returns the if-unmodified-since header for the upload session
func (*OcisSession) InitiatorID ¶
func (s *OcisSession) InitiatorID() string
InitiatorID returns the id of the initiating client
func (*OcisSession) IsProcessing ¶
func (s *OcisSession) IsProcessing() bool
IsProcessing returns true if all bytes have been received. The session then has entered postprocessing state.
func (*OcisSession) MTime ¶
func (s *OcisSession) MTime() time.Time
MTime returns the mtime to use for the uploaded file
func (*OcisSession) NodeExists ¶
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) NodeParentID ¶
func (s *OcisSession) NodeParentID() string
NodeParentID returns the nodes parent id
func (*OcisSession) Offset ¶
func (s *OcisSession) Offset() int64
Offset returns the current upload offset
func (*OcisSession) Persist ¶
func (s *OcisSession) Persist(ctx context.Context) error
Persist writes the upload session metadata to disk events can update the scan outcome and the finished event might read an empty file because of race conditions so we need to lock the file while writing and use atomic writes
func (*OcisSession) ProviderID ¶
func (s *OcisSession) ProviderID() string
ProviderID returns the provider id
func (*OcisSession) Purge ¶
func (s *OcisSession) Purge(ctx context.Context) error
Purge deletes the upload session metadata and written binary data
func (*OcisSession) Reference ¶
func (s *OcisSession) Reference() provider.Reference
Reference returns a reference that can be used to access the uploaded resource
func (*OcisSession) ScanData ¶
func (s *OcisSession) ScanData() (string, time.Time)
ScanData returns the virus scan data
func (*OcisSession) SetExecutant ¶
func (s *OcisSession) SetExecutant(u *userpb.User)
SetExecutant is used to remember the user that initiated the upload session
func (*OcisSession) SetMetadata ¶
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 ¶
func (s *OcisSession) SetScanData(result string, date time.Time)
SetScanData sets virus scan data to the upload session
func (*OcisSession) SetSize ¶
func (s *OcisSession) SetSize(size int64)
SetSize will set the upload size of the underlying tus info.
func (*OcisSession) SetSizeIsDeferred ¶
func (s *OcisSession) SetSizeIsDeferred(value bool)
SetSizeIsDeferred is uset to change the SizeIsDeferred property of the underlying tus info.
func (*OcisSession) SetStorageValue ¶
func (s *OcisSession) SetStorageValue(key, value string)
SetStorageValue is used to set metadata only relevant for the upload session implementation
func (*OcisSession) SizeDiff ¶
func (s *OcisSession) SizeDiff() int64
SizeDiff returns the size diff that was calculated after postprocessing
func (*OcisSession) SpaceOwner ¶
func (s *OcisSession) SpaceOwner() *userpb.UserId
SpaceOwner returns the id of the space owner
func (*OcisSession) Terminate ¶
func (session *OcisSession) Terminate(_ context.Context) error
Terminate terminates the upload
func (*OcisSession) ToFileInfo ¶
func (s *OcisSession) ToFileInfo() tusd.FileInfo
ToFileInfo returns tus compatible FileInfo so the tus handler can access the upload offset
func (*OcisSession) TouchBin ¶
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 ¶
func (session *OcisSession) URL(_ context.Context) (string, error)
URL returns a url to download an upload
func (*OcisSession) WriteChunk ¶
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 ¶
type OcisStore struct {
// contains filtered or unexported fields
}
OcisStore manages upload sessions
func NewSessionStore ¶
func NewSessionStore(fs storage.FS, aspects aspects.Aspects, root string, async bool, tknopts options.TokenOptions, log *zerolog.Logger) *OcisStore
NewSessionStore returns a new OcisStore
func (OcisStore) Cleanup ¶
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 ¶
func (store OcisStore) CreateNodeForUpload(ctx context.Context, 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