A modification of the code from https://github.com/rickslick/grpcUpload
imageCache can be used a CLI tool and a Server.
The CLI tool uploads files concurrently using grpc to a server instance of the application.
If the server is spurned in a container
It is Ephemeral, meaning, all data is erased once the container shuts down.
To prevent this, you can make use of volumes.
- concurrent multi file upload using grpc with concept of chunking
- supports tls (both client and sever )
- Displays progress for each file
- Exposes endpoints for file downloads
- Exposes endpoint that return list of files of uploaded
Server Exposes GRPC and REST apis
CLI communicates with the grpc server from a terminal
go run cmd/server/main.go
go run cmd/client/main.go upload 127.0.0.1:4000 -f ./testdata/sample23.png
docker build . -t <ImageTagName> imageCache
e.g docker build . -t imageCache
output:
mac@macs-MBP imageCache % docker build . -t imageCache
[+] Building 116.0s (8/11)
=> [internal] load build context 2.0s
=> => transferring context: 51.91kB 1.6s
=> [builder 1/4] FROM docker.io/library/golang:1.18-alpine@sha256
...
docker run --env-file .env -p 9900:<GRPC_PORT> -p 7700:<REST_PORT> <ImageTagName>
e.g docker run --env-file .env -p 9900:9900 -p 7700:7700 server
output:
mac@macs-MBP imageCache % docker run --env-file .env -p 9900:9900 -p 7700:7700 server
[GIN-debug] [WARNING] Creating an Engine instance with the Logger and Recovery middleware already attached.
[GIN-debug] [WARNING] Running in "debug" mode. Switch to "release" mode in production.
- using env: export GIN_MODE=release
- using code: gin.SetMode(gin.ReleaseMode)
[GIN-debug] GET /data/files/:fileName --> imageCache/delivery/server.DownloadFileHandler (3 handlers)
[GIN-debug] GET /list --> imageCache/delivery/server.ListFilesHandler (3 handlers)
======> we are running REST APIs @ :9900
=========> We are running GRPC APIs @ 127.0.0.1:7700