To upload many files from the profile photo to pdf, almost every web application needs a file upload method. If you want it to be good enough, you'll probably need to do a lot on both the backend and the frontend. We will leave frontend as the subject of another article and discuss how to upload files in an AdonisJs project efficiently using Google Cloud Storage.
It is much easier to deal with file uploads in AdonisJs than many other frameworks. However, I should say that, extending file upload and file storage functionality is not as easy as it should be. Things can get out of hand especially if you want to upload the files directly into a cloud storage in the same time while it has been streaming.
Stria and all the things what makes Stria are served on Google Cloud. For sure, Google Cloud Storage is used as file storage as well. For now, AdonisJs does not offer a native storage driver for Google Cloud Storage. In this article, we will explain the detail of how to upload files on to the Google Cloud Storage (aka Buckets) in AdonisJs framework.
Normally, in order to upload a file to an external storage, the file needs to be saved in a temporary directory first. Then it is moved from the temp directory to the destination (AWS, Space, Cloud). In this case more than one I/O read/write occurs. Although it is not easy to handle file storage on AdonisJs, there is no need for an external library to stream the file to a cloud storage, expect the provider's storage SDK.
Let’s get dive!