github.com/cs3org/reva/v2@v2.27.7/pkg/rhttp/datatx/datatx.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 datatx provides a library to abstract the complexity 20 // of using various data transfer protocols. 21 package datatx 22 23 import ( 24 "context" 25 "net/http" 26 27 userv1beta1 "github.com/cs3org/go-cs3apis/cs3/identity/user/v1beta1" 28 provider "github.com/cs3org/go-cs3apis/cs3/storage/provider/v1beta1" 29 "github.com/cs3org/reva/v2/pkg/events" 30 "github.com/cs3org/reva/v2/pkg/storage" 31 "github.com/cs3org/reva/v2/pkg/utils" 32 ) 33 34 // DataTX provides an abstraction around various data transfer protocols. 35 type DataTX interface { 36 Handler(fs storage.FS) (http.Handler, error) 37 } 38 39 // EmitFileUploadedEvent is a helper function which publishes a FileUploaded event 40 func EmitFileUploadedEvent(spaceOwnerOrManager, executant *userv1beta1.UserId, ref *provider.Reference, publisher events.Publisher) error { 41 if ref == nil || publisher == nil { 42 return nil 43 } 44 45 uploadedEv := events.FileUploaded{ 46 SpaceOwner: spaceOwnerOrManager, 47 Owner: spaceOwnerOrManager, 48 Executant: executant, 49 Ref: ref, 50 Timestamp: utils.TSNow(), 51 } 52 53 return events.Publish(context.Background(), publisher, uploadedEv) 54 }