Creating a file service server with nodejs fastify and minIO

Why create a file service server? it provides a central but independent location on your network where you can store files and share them with users across your network. This ensures that no updates destroy or change files.

MinIO is a High Performance Object Storage released under Apache License v2.0. It is API compatible with Amazon S3 cloud storage service. Use MinIO to build high performance infrastructure for machine learning, analytics and application data workloads.

So let us get started setting up the easy part. Running minIO in a docker container.

To begin with, download docker: docker is an application that simplifies the process of managing application processes in containers. Containers let you run your applications in resource-isolated processes. They’re similar to virtual machines.

to do so. follow the guideline provided by this amazing digital ocean documentation:

after uccessfullt installing docker run the command below to start minIO

docker run -p 9000:9000 \
minio/minio server /data

Open minio browser using the url and login with the provided credentials:


Now that that is out of the way let us start cooking!!

Let us use the gateway service project as our broiler plate for this project. Delete contents of the routes/v1 folder and also clear out the routes/index.ts file.

In case this is the first article you are reading, go through my gateway service article and clone the repository to get started.

Let us create a few useful utilities to use. In out utils folder let us create a minioClient.ts file which contains the access and secret key above. Since we will be testing this on our local machine, ensure useSSL is false. The port should be the default 9000 and url endpoint

Another utility file we need to create is the makeBucket.ts file which accepts folder name ad argument and is responsible for creating buckets in simple terms, it will create folders where we will store our uploaded files.

let us create our routes to handle singe and multiple image uploads. We will still use the schema format that we used in the gateway service. The body will accept a folder name which will be used to create buckets.

And now for our controller.

to ensure the uploaded files can be viewed in the browser, we need to add metadata to the binary file to be uploaded.

Now let us make our route accessible.

Now let us make a request with postman.

View of uploaded files in minIO

Preview of one image

Return response with urls to uploaded files.

I am an experienced back-end software engineer adept in bringing forth expertise in design, installation, testing and maintenance of software systems.

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store