Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Uploading files to Firebase Storage using REST API

Right now, the Firebase documentation guides you on uploading files to Firebase Storage by using their JavaScript library.

I am operating a server without NodeJS installed. Is it possible to upload files like image, audio, through the Firebase REST API?

At the moment I am using curl in a bash script to send JSON. I would prefer not to store base64 encoding in a database field, I want the file to be stored in a folder inside the Storage section.

Storage folder shown below:

Storage Folder

like image 653
cnic Avatar asked Jun 04 '16 14:06

cnic


1 Answers

Firebase Storage uses Google Cloud Storage under the hood, so you can use the GCS REST API to get 90% of the way there. (Docs here.)

There's a couple differences.

  1. Download URLs won't be automatically generated until you access it through the Firebase Storage SDK.
  2. You won't be able to use Firebase Authentication to upload through the GCS REST endpoint. You'll either need to set up OAuth (which, you might be able to get through Google Sign in with Authentication) or a service account. (Here's an example of how you can authenticate from Node.js to GCS.)
like image 51
katfang Avatar answered Sep 28 '22 01:09

katfang