-
Notifications
You must be signed in to change notification settings - Fork 13
/
uploader.go
35 lines (26 loc) · 995 Bytes
/
uploader.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
package registry
import (
"github.com/sarulabs/di"
tusd "github.com/tus/tusd/pkg/handler"
"github.com/coretrix/hitrix/service"
"github.com/coretrix/hitrix/service/component/oss"
"github.com/coretrix/hitrix/service/component/uploader"
"github.com/coretrix/hitrix/service/component/uploader/locker"
)
func ServiceProviderUploader(c tusd.Config, getLockerFunc locker.GetLockerFunc) *service.DefinitionGlobal {
return &service.DefinitionGlobal{
Name: service.UploaderService,
Build: func(ctn di.Container) (interface{}, error) {
osService := ctn.Get(service.OSService).(oss.IProvider)
uploaderBucketName := osService.GetBucketConfig(oss.BucketPublic).Name
composer := tusd.NewStoreComposer()
store := uploader.GetStore(osService.GetClient(), uploaderBucketName)
store.UseIn(composer)
if getLockerFunc != nil {
composer.UseLocker(getLockerFunc(ctn))
}
c.StoreComposer = composer
return uploader.NewTUSDUploader(c, uploaderBucketName), nil
},
}
}