Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Set chunk number #75

Merged
merged 1 commit into from
Nov 15, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 12 additions & 21 deletions cmd/gateway/zcn/dStorage.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ import (
"time"

zerror "github.com/0chain/errors"
"github.com/0chain/gosdk/constants"
"github.com/0chain/gosdk/zboxcore/sdk"
"github.com/0chain/gosdk/zboxcore/zboxutil"
"github.com/minio/minio/internal/logger"
"github.com/mitchellh/go-homedir"
)
Expand Down Expand Up @@ -200,11 +200,6 @@ func getFileReader(ctx context.Context, alloc *sdk.Allocation, remotePath string

func putFile(ctx context.Context, alloc *sdk.Allocation, remotePath, contentType string, r io.Reader, size int64, isUpdate, shouldEncrypt bool) (err error) {
logger.Info("started PutFile")
cb := &statusCB{
doneCh: make(chan struct{}, 1),
errCh: make(chan error, 1),
}

_, fileName := filepath.Split(remotePath)
fileMeta := sdk.FileMeta{
Path: "",
Expand All @@ -220,28 +215,24 @@ func putFile(ctx context.Context, alloc *sdk.Allocation, remotePath, contentType
return err
}

logger.Info("creating chunked upload")
chunkUpload, err := sdk.CreateChunkedUpload(workDir, alloc, fileMeta, newMinioReader(r), isUpdate, false, false, zboxutil.NewConnectionId(),
sdk.WithStatusCallback(cb),
)

if err != nil {
logger.Error(err.Error())
return
logger.Info("starting chunked upload")
opRequest := sdk.OperationRequest{
OperationType: constants.FileOperationInsert,
FileReader: newMinioReader(r),
Workdir: workDir,
RemotePath: remotePath,
FileMeta: fileMeta,
Opts: []sdk.ChunkedUploadOption{
sdk.WithChunkNumber(250),
},
}

err = chunkUpload.Start()
err = alloc.DoMultiOperation([]sdk.OperationRequest{opRequest})
if err != nil {
logger.Info("error from PutFile")
logger.Error(err.Error())
return
}

select {
case <-cb.doneCh:
case err = <-cb.errCh:
}

return
}

Expand Down
1 change: 1 addition & 0 deletions cmd/gateway/zcn/gateway-zcn.go
Original file line number Diff line number Diff line change
Expand Up @@ -599,6 +599,7 @@ func (zob *zcnObjects) PutMultipleObjects(

options := []sdk.ChunkedUploadOption{
sdk.WithEncrypt(false),
sdk.WithChunkNumber(200),
}
operationRequests[idx] = sdk.OperationRequest{
FileMeta: fileMeta,
Expand Down