github.com/cs3org/reva/v2@v2.27.7/pkg/storage/uploads.go (about) 1 // Copyright 2018-2021 CERN 2 // 3 // Licensed under the Apache License, Version 2.0 (the "License"); 4 // you may not use this file except in compliance with the License. 5 // You may obtain a copy of the License at 6 // 7 // http://www.apache.org/licenses/LICENSE-2.0 8 // 9 // Unless required by applicable law or agreed to in writing, software 10 // distributed under the License is distributed on an "AS IS" BASIS, 11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 // See the License for the specific language governing permissions and 13 // limitations under the License. 14 // 15 // In applying this license, CERN does not waive the privileges and immunities 16 // granted to it by virtue of its status as an Intergovernmental Organization 17 // or submit itself to any jurisdiction. 18 19 package storage 20 21 import ( 22 "context" 23 "io" 24 "time" 25 26 userpb "github.com/cs3org/go-cs3apis/cs3/identity/user/v1beta1" 27 provider "github.com/cs3org/go-cs3apis/cs3/storage/provider/v1beta1" 28 tusd "github.com/tus/tusd/v2/pkg/handler" 29 ) 30 31 // UploadFinishedFunc is a callback function used in storage drivers to indicate that an upload has finished 32 type UploadFinishedFunc func(spaceOwner, executant *userpb.UserId, ref *provider.Reference) 33 34 // UploadRequest us used in FS.Upload() to carry required upload metadata 35 type UploadRequest struct { 36 Ref *provider.Reference 37 Body io.ReadCloser 38 Length int64 39 } 40 41 // UploadsManager defines the interface for storage drivers that allow for managing uploads 42 // Deprecated: No longer used. Storage drivers should implement the UploadSessionLister. 43 type UploadsManager interface { 44 ListUploads() ([]tusd.FileInfo, error) 45 PurgeExpiredUploads(chan<- tusd.FileInfo) error 46 } 47 48 // UploadSessionLister defines the interface for FS implementations that allow listing and purging upload sessions 49 type UploadSessionLister interface { 50 // ListUploadSessions returns the upload sessions matching the given filter 51 ListUploadSessions(ctx context.Context, filter UploadSessionFilter) ([]UploadSession, error) 52 } 53 54 // UploadSession is the interface that storage drivers need to return whan listing upload sessions. 55 type UploadSession interface { 56 // ID returns the upload id 57 ID() string 58 // Filename returns the filename of the file 59 Filename() string 60 // Size returns the size of the upload 61 Size() int64 62 // Offset returns the current offset 63 Offset() int64 64 // Reference returns a reference for the file being uploaded. May be absolute id based or relative to e.g. a space root 65 Reference() provider.Reference 66 // Executant returns the userid of the user that created the upload 67 Executant() userpb.UserId 68 // SpaceOwner returns the owner of a space if set. optional 69 SpaceOwner() *userpb.UserId 70 // Expires returns the time when the upload can no longer be used 71 Expires() time.Time 72 73 // IsProcessing returns true if postprocessing has not finished, yet 74 // The actual postprocessing state is tracked in the postprocessing service. 75 IsProcessing() bool 76 77 // Purge allows completely removing an upload. Should emit a PostprocessingFinished event with a Delete outcome 78 Purge(ctx context.Context) error 79 80 // ScanData returns the scan data for the UploadSession 81 ScanData() (string, time.Time) 82 } 83 84 // UploadSessionFilter can be used to filter upload sessions 85 type UploadSessionFilter struct { 86 ID *string 87 Processing *bool 88 Expired *bool 89 HasVirus *bool 90 }