using Firebase auth and storage to store files on behalf of users w/o server component?

125 views
Skip to first unread message

Chris Dawson

unread,
Nov 8, 2016, 5:10:02 PM11/8/16
to Firebase Google Group
I'm learning about Firebase auth and storage in a web app. My idea asks users to login via Firebase and then upload an image. 

I can see that this is possible from firebase auth and storage. However, I would like to put limits on the file count and file-size they can upload. 

Is it possible to control uploads within the firebase console? After reviewing the JavaScript examples, I see how I can put files in, and I can imagine writing code which would query firebase for a user's upload count, and then limit on the client side, but of course, this is a completely insecure method.

If I hosted this as a single page app on, say, GitHub pages, I am wondering if I could set these limits without involving a server. Or, do I need to proxy my uploads through a server to make sure I never allow users to upload more than I intend them to?

If you have documentation on this type of idea, I'm very happy to get it, on top of any advice in this thread.

Thanks in advance.

Chris

Jacob Wenger

unread,
Nov 9, 2016, 3:20:29 PM11/9/16
to fireba...@googlegroups.com
Hey there,

I'm not sure if this will totally solve your problem, but Firebase Storage Rules can do some of this for you. For example, you can limit the size of a file via the Storage Rules (Look for size in the table here; API reference here). I'm not sure if you can limit the number of files directly via the Storage Rules, but you could store the file count in the Realtime Database and then use the Database Rules to limit that count (e.g. ".write": "newData.child('fileCount').val() <= 10").

I'd suggest reading through the docs I linked to above and seeing if they will solve your problem.

Cheers,
Jacob

--
You received this message because you are subscribed to the Google Groups "Firebase Google Group" group.
To unsubscribe from this group and stop receiving emails from it, send an email to firebase-talk+unsubscribe@googlegroups.com.
To post to this group, send email to fireba...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/firebase-talk/1967b8e2-7cec-45d0-9f32-7bf05221f956%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply all
Reply to author
Forward
0 new messages