To get started, create a directory
image-server and change the current directory into it.
Before we begin, let's install all the necessary dependencies for this project.
In this tutorial, we are using
express to build our server, and
express-fileupload allows us to access the uploaded file data.
To configure the app, import the dependencies and instantiate drive in
We have everything we need to 🚀
First, we need to render a HTML snippet to display the file upload interface.
We'll expose a function that renders the HTML snippet on the base route
We are simply rendering a HTML form that sends a HTTP
POST request to the route
/upload with file data.
Let's complete file upload by creating a function to handle
We can access the image details from
req and store it in Drive.
To download images, we can simply use
If we tie a
GET request to the
/download path with a param giving a name (i.e
/download/space.png), we can return the image over HTTP.
To run the server locally, navigate to the terminal in the project directory (
image-server) and run the following command:
If you run into any issues, consider reporting them in our Github Discussions.