Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added support for Firebase Storage & Firebase Functions #38

Open
wants to merge 23 commits into
base: master
Choose a base branch
from

Conversation

wkok
Copy link

@wkok wkok commented Jul 9, 2020

Thank you for this library, I find it extremely useful.

Currently you have wrappers for Firebase Authentication, Realtime Database & FireStore

I thought it useful to include basic operations of Firebase Storage and Firebase Functions submitted via this Pull Request.

Storage

re-frame effects are implemented for basic Storage functions put, delete & download-url

Put

Puts a collection of File objects into a Firebase Storage bucket.
See: https://firebase.google.com/docs/storage/web/upload-files

Required arguments :path :file

  • :path Path to object in the Storage bucket
  • :file File (https://developer.mozilla.org/en-US/docs/Web/API/File)
  • :bucket If not supplied, will assume the default Firebase allocated bucket
  • :metadata Map of metadata to set on Storage object
  • :on-progress Will be provided with the percentage complete
  • :on-success
  • :on-error

Example FX:

   {:storage/put [{:path "path/to/object"
                   :file File
                   :metadata {:customMetadata {"some-key" "some-value"}}
                   :on-progress #(.log js/console (str "Upload is " % "% complete."))
                   :on-success #(js/alert "Success!")
                   :on-error #(js/alert "Error: " %)}]}

Delete

Deletes a collection of object paths/keys from a Firebase Storage bucket.
See: https://firebase.google.com/docs/storage/web/delete-files

Required arguments :path

  • :path Path to object in the Storage bucket
  • :bucket If not supplied, will assume the default Firebase allocated bucket
  • :on-success
  • :on-error

Example FX:

  {:storage/delete [{:path "path/to/object"
                     :on-success #(js/alert "Success!")
                     :on-error #(js/alert "Error: " %)}]}

Download URL

Generates a url with which the browser can download an object from Firebase Storage
See: https://firebase.google.com/docs/storage/web/download-files

Required arguments: :path

  • :path Path to object in the Storage bucket
  • :bucket If not supplied, will assume the default Firebase allocated bucket
  • :on-success Will be provided with the download url
  • :on-error

Example FX:

  {:storage/download-url {:path "path/to/object"
                          :on-success #(js/window.open %)
                          :on-error #(js/alert "Error: " %)}}

Functions

re-frame effects are implemented for basic Functions of call

Call

Executes a Callable Firebase Cloud Function
See: https://firebase.google.com/docs/functions/callable

Required arguments: :cfn-name :data

  • :cfn-name Cloud Function name
  • :data Map containing request data
  • :on-success Will be called with a clojure Map containing the response data
  • :on-error

Example FX:

  {:functions/call {:cfn-name "my-function-name"
                    :data {:foo "bar"} 
                    :on-success #(js/alert (:foobar %))
                    :on-error #(js/alert "Error: " %)}}

@jumski
Copy link

jumski commented Jul 9, 2020

What a synchronicity, i was searching for storage in this repo like 5 minutes after your pull request ;)
how can i help in getting this merged? would love to use it!

@wkok wkok changed the title Added support for Firebase Storage Added support for Firebase Storage & Firebase Functions Jul 11, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants