Client streaming
FileUpload Service
The client streams many messages (e.g. file chunks) and the server replies once at the end with a summary.
many requests → 1 response
1. The contract
This is real gRPC code. It defines the service and messages.
fileupload.proto
syntax = "proto3";
package demo;
// CLIENT STREAMING: a stream of requests, one reply
service FileUpload {
rpc Upload (stream Chunk) returns (UploadSummary);
}
message Chunk {
bytes data = 1;
int32 sequence = 2;
}
message UploadSummary {
int32 chunks_received = 1;
int64 total_bytes = 2;
bool success = 3;
}2. Live simulation
Watch how messages flow for this pattern.
// Press the button to start the Client streaming demo.