Submit forms with files to Google Cloud Functions
HTTP-triggered Cloud Functions have essentially the same characteristics and capabilities as a web application running on App Engine or Cloud Run, but their code is shorter and is more to the point.
Sometimes cloud functions can be a good alternative to traditional web server-based backends. For example, in cloud functions it simple to use Google API. So cloud functions are an ideal option for creation of backend services that process received data in the Google Cloud and then save the results to the Google Drive or Sheets.
In this post I explore how to employ a cloud function handling files submitted by a web page. I use a web page as the client because it has a user interface. But the client does not need to be a web page. Regardless of the client type, files are typically sent over the network as POST requests with multipart/form-data
format. The same function can handle any clients, e.g. browser extension or another function.
Web page for uploading files to the backend
My sample web page allows submitting multiple files together with the metadata entered in other form controls. The HTML form includes a text
input
, select
and two file
input
s…