refactor: return s3 client instance with BuildUploadBufferTus

This commit is contained in:
Derrick Hammer 2024-01-22 18:51:09 -05:00
parent bf36562fca
commit da298cc56f
Signed by: pcfreak30
GPG Key ID: C997C339BE476FF2
2 changed files with 4 additions and 4 deletions

View File

@ -13,7 +13,7 @@ type StorageService interface {
Portal() Portal
PutFileSmall(file io.ReadSeeker, bucket string, generateProof bool) ([]byte, error)
PutFile(file io.Reader, bucket string, hash []byte) error
BuildUploadBufferTus(basePath string, preUploadCb TusPreUploadCreateCallback, preFinishCb TusPreFinishResponseCallback) (*tusd.Handler, tusd.DataStore, error)
BuildUploadBufferTus(basePath string, preUploadCb TusPreUploadCreateCallback, preFinishCb TusPreFinishResponseCallback) (*tusd.Handler, tusd.DataStore, *s3.Client, error)
FileExists(hash []byte) (bool, models.Upload)
GetHashSmall(file io.ReadSeeker) ([]byte, error)
GetHash(file io.Reader) ([]byte, error)

View File

@ -118,7 +118,7 @@ func (s StorageServiceImpl) PutFile(file io.Reader, bucket string, hash []byte)
return nil
}
func (s *StorageServiceImpl) BuildUploadBufferTus(basePath string, preUploadCb interfaces.TusPreUploadCreateCallback, preFinishCb interfaces.TusPreFinishResponseCallback) (*tusd.Handler, tusd.DataStore, error) {
func (s *StorageServiceImpl) BuildUploadBufferTus(basePath string, preUploadCb interfaces.TusPreUploadCreateCallback, preFinishCb interfaces.TusPreFinishResponseCallback) (*tusd.Handler, tusd.DataStore, *s3.Client, error) {
customResolver := aws.EndpointResolverWithOptionsFunc(func(service, region string, options ...interface{}) (aws.Endpoint, error) {
if service == s3.ServiceID {
return aws.Endpoint{
@ -139,7 +139,7 @@ func (s *StorageServiceImpl) BuildUploadBufferTus(basePath string, preUploadCb i
config.WithEndpointResolverWithOptions(customResolver),
)
if err != nil {
return nil, nil, nil
return nil, nil, nil, nil
}
s3Client := s3.NewFromConfig(cfg)
@ -162,7 +162,7 @@ func (s *StorageServiceImpl) BuildUploadBufferTus(basePath string, preUploadCb i
PreUploadCreateCallback: preUploadCb,
})
return handler, store, err
return handler, store, s3Client, err
}
func (s *StorageServiceImpl) Init() error {