Skip to content

Commit 45c776c

Browse files
authored
Merge pull request #75 from 0chain/fix/download-obj
Set chunk number
2 parents e9dab84 + c22617f commit 45c776c

File tree

2 files changed

+13
-21
lines changed

2 files changed

+13
-21
lines changed

cmd/gateway/zcn/dStorage.go

Lines changed: 12 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@ import (
1111
"time"
1212

1313
zerror "github.com/0chain/errors"
14+
"github.com/0chain/gosdk/constants"
1415
"github.com/0chain/gosdk/zboxcore/sdk"
15-
"github.com/0chain/gosdk/zboxcore/zboxutil"
1616
"github.com/minio/minio/internal/logger"
1717
"github.com/mitchellh/go-homedir"
1818
)
@@ -200,11 +200,6 @@ func getFileReader(ctx context.Context, alloc *sdk.Allocation, remotePath string
200200

201201
func putFile(ctx context.Context, alloc *sdk.Allocation, remotePath, contentType string, r io.Reader, size int64, isUpdate, shouldEncrypt bool) (err error) {
202202
logger.Info("started PutFile")
203-
cb := &statusCB{
204-
doneCh: make(chan struct{}, 1),
205-
errCh: make(chan error, 1),
206-
}
207-
208203
_, fileName := filepath.Split(remotePath)
209204
fileMeta := sdk.FileMeta{
210205
Path: "",
@@ -220,28 +215,24 @@ func putFile(ctx context.Context, alloc *sdk.Allocation, remotePath, contentType
220215
return err
221216
}
222217

223-
logger.Info("creating chunked upload")
224-
chunkUpload, err := sdk.CreateChunkedUpload(workDir, alloc, fileMeta, newMinioReader(r), isUpdate, false, false, zboxutil.NewConnectionId(),
225-
sdk.WithStatusCallback(cb),
226-
)
227-
228-
if err != nil {
229-
logger.Error(err.Error())
230-
return
218+
logger.Info("starting chunked upload")
219+
opRequest := sdk.OperationRequest{
220+
OperationType: constants.FileOperationInsert,
221+
FileReader: newMinioReader(r),
222+
Workdir: workDir,
223+
RemotePath: remotePath,
224+
FileMeta: fileMeta,
225+
Opts: []sdk.ChunkedUploadOption{
226+
sdk.WithChunkNumber(250),
227+
},
231228
}
232229

233-
err = chunkUpload.Start()
230+
err = alloc.DoMultiOperation([]sdk.OperationRequest{opRequest})
234231
if err != nil {
235-
logger.Info("error from PutFile")
236232
logger.Error(err.Error())
237233
return
238234
}
239235

240-
select {
241-
case <-cb.doneCh:
242-
case err = <-cb.errCh:
243-
}
244-
245236
return
246237
}
247238

cmd/gateway/zcn/gateway-zcn.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -599,6 +599,7 @@ func (zob *zcnObjects) PutMultipleObjects(
599599

600600
options := []sdk.ChunkedUploadOption{
601601
sdk.WithEncrypt(false),
602+
sdk.WithChunkNumber(200),
602603
}
603604
operationRequests[idx] = sdk.OperationRequest{
604605
FileMeta: fileMeta,

0 commit comments

Comments
 (0)