Simple example for file transfer using gRPC Stream.
- Server: Go
- Client: Dart
-
Go >= 1.5 - For install instructions Click Here
-
Dart >= 2.2.2 <= 3.0.0 - For install instructions Click Here
-
protoc (Protobuf Compiler) - For install instructions Click Here
-
protoc-gen-go plugin
export GO111MODULE=on
go get github.com/golang/protobuf/protoc-gen-go
- protoc-gen-go-grpc plugin
export GO111MODULE=on
go get google.golang.org/grpc/cmd/protoc-gen-go-grpc
- protoc-gen-dart plugin
pub global activate protoc_plugin
The last protos for this example already have been genereted and commited, but if you need to regenerate the protos use the instructions below:
By default ⇧ + CTRL + P(Linux/Windows) ou ⇧ + ⌘ + P(Mac) opens the command prompt. Type one of these commands:
Command | Description |
---|---|
proto3: Compile All Protos |
Compiles all workspace protos using configurations defined with protoc.options . |
proto3: Compile This Proto |
Compiles the active proto using configurations defined with protoc.options . |
This project has include .vscode/settings with necessary configs for vscode-proto3, open this file and uncomment "--plugin" parameters with absolute path for protoc-gen-dart, protoc-gen-go, protoc-gen-go-grpc case default configs doesn't works properly and get error with unknown path for this plugins.
Open terminal and cd for project root:
cd PROJECT_ROOT
protoc --plugin="protoc-gen-go=[absolute_path_to]/protoc-gen-go" \
--plugin="protoc-gen-go-grpc=[absolute_path_to]/protoc-gen-go-grpc" \
--plugin="protoc-gen-dart=[absolute_path_to]/protoc-gen-dart" \
--proto_path=${PWD} \
--dart_out="grpc:./client/lib/src" \
--go_out="./server" \
--go-grpc_out="./server" \
proto/grpc_file_transfer.proto
- Run Server:
cd server/
go run main.go
- Run Client:
cd client/
dart --packages=.dart_tool/package_config.json package:grpcfiletransfer/src/client.dart
Video Example by File Examples