Client cut allows for splitting the uploaded object into chunks on the client side,
with the ability to pause and resume uploads, as well as control the size of the chunks.
There is currently no way to resume downloading in this implementation.
bufferMaxSize defines the size of the uploaded chunk. It is compared with the maxObjectSize parameter in the network settings, and the smaller value is selected
objectHeader the object header
isPayloadPositioned a parameter required for resuming uploads, indicating whether the data stream has been positioned correctly for resumption or not
privatestaticObjectIdresumableUpload(FrostFSClientclient,ContainerIdcontainerId,StringfilePath,intbufferMaxSize,CallContextcallContext,booleanpayloadPositionedByClient){varattribute=newObjectAttribute("Filename",Paths.get(filePath).getFileName().toString());varheader=newObjectHeader(containerId,ObjectType.REGULAR,attribute);varprmObjectClientCutPut=PrmObjectClientCutPut.builder().objectHeader(header).bufferMaxSize(bufferMaxSize).isPayloadPositioned(payloadPositionedByClient).listener((uploadProgressInfo,objectPartInfo)->System.out.printf("Uploaded: %d/%d%n",uploadProgressInfo.getParts().size(),uploadProgressInfo.getTotalParts())).build();try(UnstableFileInputStreamfile=newUnstableFileInputStream(filePath,FAIL_AFTER_READ_BYTES)){prmObjectClientCutPut.setPayload(file);returnclient.putClientCutObject(prmObjectClientCutPut,callContext);}catch(IOException|FrostFSExceptione){try(FileInputStreamfile=newFileInputStream(filePath)){if(payloadPositionedByClient){varprogressInfo=prmObjectClientCutPut.getUploadProgressInfo();varlastPart=progressInfo.getParts().get(progressInfo.getParts().size()-1);longoffset=lastPart.getOffset()+lastPart.getLength();longskippedBytes=file.skip(offset);if(skippedBytes!=offset){thrownewRuntimeException("Skipped less bytes than expected");}}prmObjectClientCutPut.setPayload(file);returnclient.putClientCutObject(prmObjectClientCutPut,callContext);}catch(IOExceptionex){thrownewRuntimeException("Failed to upload object after retry",ex);}}}