Upload files to GCP using multer , nodejs with visibility as public.

Athira V Ajit
2 min readJan 1, 2021

While searching and reading blog posts on how to upload files to GCP using multer in NodeJS , I had found overwhelming number of posts for the same but one thing I failed to find (maybe I missed a post explaining that topic) is how to automatically make a file public through nodeJS request(though the method for making the url public was mentioned yet the file shows access denied unless its permissions are changed). So the only way I found was to go to the console and change the permission for the files through the dropdown one at a time or through the cmd line in bulk. But that was not the functionality I was planning to achieve. I required my file permissions to be also set as public by default.

After some days I was working on a project which had s3 upload for AWS. I saw in the request my colleague had written ACL: ‘public-read’ as part of the request params.

That’s when it struck to me VOILA so this was the point I was missing. I did feel a bit stupid thinking I should have read the documentation properly but nevertheless I was overjoyed knowing I had found the solution to my unending search in the past few weeks.

I refined my search in this direction to find how GCP does the same. And EUREKA !!!! guess what I found my solution. So if you are wondering what it was ,here you go

predefinedAcl : ‘publicRead’

these where the magical characters which will automatically make your files as public without going through the pain of traversing to the console .

I hope this post helps some of the peeps who had missed out on this part , if there are any :)

Lessons learnt

  1. Read the documentations carefully.
  2. Also its great to try different languages and projects parallelly , you never know while working on one project you might find the solution to another. (Disclaimer : That's not the case always. But do give it a try.)

Cheers to more useful content and more lessons learnt from mistakes made everyday.

Guys do give it a clap if you feel this post helped you in any manner.

Also lets connect on linkedIn : https://www.linkedin.com/in/athira-v-ajit/

Feel free to check my github repo as well : https://github.com/Athira2199

--

--