Skip to content
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
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ test:
go test ./...;

lint:
golangci-lint run;
golangci-lint run --timeout 2m0s;

integration-tests:
go test ./... -args integration;
463 changes: 346 additions & 117 deletions code/go/0chain.net/blobbercore/blobbergrpc/blobber.pb.go

Large diffs are not rendered by default.

115 changes: 115 additions & 0 deletions code/go/0chain.net/blobbercore/blobbergrpc/blobber.pb.gw.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

36 changes: 36 additions & 0 deletions code/go/0chain.net/blobbercore/blobbergrpc/blobber_grpc.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

24 changes: 24 additions & 0 deletions code/go/0chain.net/blobbercore/blobbergrpc/proto/blobber.proto
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,12 @@ service Blobber {
get: "/v2/file/objecttree/{allocation}"
};
}
rpc RenameObject(RenameObjectRequest) returns (RenameObjectResponse) {
option (google.api.http) = {
post: "/v2/file/rename/{allocation}"
body: "*"
};
}

rpc Commit(CommitRequest) returns (CommitResponse) {
option (google.api.http) = {
Expand Down Expand Up @@ -286,6 +292,24 @@ message CopyObjectResponse {
int64 upload_offset = 6;
}

message RenameObjectRequest {
string allocation = 1;
string path = 2;
string path_hash = 3;
string connection_id = 4;
string new_name = 5;
}
message RenameObjectResponse {
string filename = 1;
int64 size = 2;
string content_hash = 3;
string merkle_root = 4;
//UploadLength indicates the size of the entire upload in bytes. The value MUST be a non-negative integer.
int64 upload_length = 5;
//Upload-Offset indicates a byte offset within a resource. The value MUST be a non-negative integer.
int64 upload_offset = 6;
}

message Allocation {
string ID = 1;
string Tx = 2;
Expand Down
16 changes: 16 additions & 0 deletions code/go/0chain.net/blobbercore/convert/responseHandler.go
Original file line number Diff line number Diff line change
Expand Up @@ -354,3 +354,19 @@ func CopyObjectResponseHandler(copyObjectResponse *blobbergrpc.CopyObjectRespons
UploadOffset: copyObjectResponse.UploadOffset,
}
}

func RenameObjectResponseCreator(r interface{}) *blobbergrpc.RenameObjectResponse {
if r == nil {
return nil
}

httpResp, _ := r.(*blobberHTTP.UploadResult)
return &blobbergrpc.RenameObjectResponse{
Filename: httpResp.Filename,
Size: httpResp.Size,
ContentHash: httpResp.Hash,
MerkleRoot: httpResp.MerkleRoot,
UploadLength: httpResp.UploadLength,
UploadOffset: httpResp.UploadOffset,
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -49,3 +49,24 @@ func (b *blobberGRPCService) CopyObject(ctx context.Context, req *blobbergrpc.Co

return convert.CopyObjectResponseCreator(resp), nil
}

func (b *blobberGRPCService) RenameObject(ctx context.Context, req *blobbergrpc.RenameObjectRequest) (*blobbergrpc.RenameObjectResponse, error) {
r, err := http.NewRequest("POST", "", nil)
if err != nil {
return nil, err
}
httpRequestWithMetaData(r, GetGRPCMetaDataFromCtx(ctx), req.Allocation)
r.Form = map[string][]string{
"path": {req.Path},
"path_hash": {req.PathHash},
"connection_id": {req.ConnectionId},
"new_name": {req.NewName},
}

resp, err := RenameHandler(ctx, r)
if err != nil {
return nil, err
}

return convert.RenameObjectResponseCreator(resp), nil
}
Loading