refactor: update parameters and change MultipartUpload to UploadObjectMultipart

This commit is contained in:
Derrick Hammer 2024-02-16 21:58:34 -05:00
parent 1812b9cd38
commit d7da471b8b
Signed by: pcfreak30
GPG Key ID: C997C339BE476FF2
1 changed files with 12 additions and 14 deletions

View File

@ -4,6 +4,11 @@ import (
"context" "context"
"errors" "errors"
"fmt" "fmt"
"io"
"math"
"net/url"
"strconv"
"git.lumeweb.com/LumeWeb/portal/cron" "git.lumeweb.com/LumeWeb/portal/cron"
"github.com/google/uuid" "github.com/google/uuid"
"github.com/spf13/viper" "github.com/spf13/viper"
@ -14,10 +19,6 @@ import (
workerClient "go.sia.tech/renterd/worker/client" workerClient "go.sia.tech/renterd/worker/client"
"go.uber.org/fx" "go.uber.org/fx"
"go.uber.org/zap" "go.uber.org/zap"
"io"
"math"
"net/url"
"strconv"
) )
type ReaderFactory func(start uint, end uint) (io.ReadCloser, error) type ReaderFactory func(start uint, end uint) (io.ReadCloser, error)
@ -71,10 +72,8 @@ func (r *RenterDefault) CreateBucketIfNotExists(bucket string) error {
return nil return nil
} }
if err != nil { if !errors.Is(err, api.ErrBucketNotFound) {
if !errors.Is(err, api.ErrBucketNotFound) { return err
return err
}
} }
err = r.busClient.CreateBucket(context.Background(), bucket, api.CreateBucketOptions{ err = r.busClient.CreateBucket(context.Background(), bucket, api.CreateBucketOptions{
@ -89,8 +88,8 @@ func (r *RenterDefault) CreateBucketIfNotExists(bucket string) error {
return nil return nil
} }
func (r *RenterDefault) UploadObject(ctx context.Context, file io.Reader, bucket string, hash string) error { func (r *RenterDefault) UploadObject(ctx context.Context, file io.Reader, bucket string, fileName string) error {
_, err := r.workerClient.UploadObject(ctx, file, bucket, hash, api.UploadObjectOptions{}) _, err := r.workerClient.UploadObject(ctx, file, bucket, fileName, api.UploadObjectOptions{})
if err != nil { if err != nil {
return err return err
@ -120,8 +119,8 @@ func (r *RenterDefault) init() error {
return nil return nil
} }
func (r *RenterDefault) GetObject(ctx context.Context, protocol string, hash string, options api.DownloadObjectOptions) (*api.GetObjectResponse, error) { func (r *RenterDefault) GetObject(ctx context.Context, bucket string, fileName string, options api.DownloadObjectOptions) (*api.GetObjectResponse, error) {
return r.workerClient.GetObject(ctx, protocol, hash, options) return r.workerClient.GetObject(ctx, bucket, fileName, options)
} }
func (r *RenterDefault) GetSetting(ctx context.Context, setting string, out any) error { func (r *RenterDefault) GetSetting(ctx context.Context, setting string, out any) error {
@ -134,12 +133,11 @@ func (r *RenterDefault) GetSetting(ctx context.Context, setting string, out any)
return nil return nil
} }
func (r *RenterDefault) MultipartUpload(params MultiPartUploadParams) error { func (r *RenterDefault) UploadObjectMultipart(ctx context.Context, params *MultiPartUploadParams) error {
size := params.Size size := params.Size
rf := params.ReaderFactory rf := params.ReaderFactory
bucket := params.Bucket bucket := params.Bucket
fileName := params.FileName fileName := params.FileName
ctx := context.Background()
idHandler := params.UploadIDHandler idHandler := params.UploadIDHandler
var redundancy api.RedundancySettings var redundancy api.RedundancySettings