A high-performance file upload/download server built with gRPC in Go, including:
- Stream-based Upload & Download RPCs
- REST API via gRPC-Gateway
- Cobra-based CLI client with progress indicators
- Benchmarking to compare gRPC vs REST
- Go 1.20+
protoc(Protocol Buffers compiler)protoc-gen-go,protoc-gen-go-grpc,protoc-gen-grpc-gatewaymake- curl (for REST benchmarking)
go install google.golang.org/protobuf/cmd/protoc-gen-go@latest
go install google.golang.org/grpc/cmd/protoc-gen-go-grpc@latest
go install github.com/grpc-ecosystem/grpc-gateway/v2/protoc-gen-grpc-gateway@latestMake sure GOPATH/bin is in your $PATH:
export PATH="$PATH:$(go env GOPATH)/bin".
├── proto/ # .proto definitions
├── pb/ # generated code
├── cmd/ # CLI client using Cobra
├── server/ # server implementation
├── uploads/ # uploaded/downloaded files
├── third_party/google/api/annotations.proto
├── Makefile
├── main.go
└── README.md
make protomake run-servermake run-client-servermake run-server
go run client/main.go upload myfile.pdfmake run-server
go run client/main.go download myfile.pdf downloads/download_You will see progress bars for both upload and download.
dd if=/dev/urandom of=bigfile.bin bs=1M count=100time go run client/main.go upload bigfile.binusing base64 if chunks are JSON bytes:
base64 -i bigfile.bin -o base64.txt
echo '{"filename": "bigfile.bin", "file": "'"$(< base64.txt)"'"}' > upload.json
curl -X POST http://localhost:8080/v1/upload \
-H "Content-Type: application/json" \
--data-binary @upload.json- gRPC is significantly faster and more efficient for large binary data due to protocol buffers.
- REST JSON encoding (especially base64 for bytes) adds overhead.
- This project demonstrates how to bridge both worlds (gRPC + REST) using gRPC-Gateway.
make cleanMIT