A modification of the code from

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. 
by default: all uploaded images are stored in /app/data/files

Featues :
  • 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

How it works

Screenshot 2022-06-19 at 13 20 11

Server Exposes GRPC and REST apis

CLI communicates with the grpc server from a terminal

Quick Start

1. spin off server

go run cmd/server/main.go

more …

2. upload a file

go run cmd/client/main.go upload -f ./testdata/sample23.png

more …

Quick Start

Working with Container (e.g Docker)

1. Build Docker container

docker build . -t <ImageTagName> imageCache

e.g docker build . -t imageCache


[email protected] 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[email protected]

2. Run Container (locally)

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  


[email protected] 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 @


View Github