From da298cc56fa913302f350fefbed314361f67833b Mon Sep 17 00:00:00 2001 From: Derrick Hammer Date: Mon, 22 Jan 2024 18:51:09 -0500 Subject: [PATCH] refactor: return s3 client instance with BuildUploadBufferTus --- interfaces/storage.go | 2 +- storage/storage.go | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/interfaces/storage.go b/interfaces/storage.go index 824d9d4..936c06d 100644 --- a/interfaces/storage.go +++ b/interfaces/storage.go @@ -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) diff --git a/storage/storage.go b/storage/storage.go index 01e1bf3..08da0d8 100644 --- a/storage/storage.go +++ b/storage/storage.go @@ -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 {