Resize image when serving

1,013 views
Skip to first unread message

Felix Halim

unread,
Jan 15, 2017, 7:45:13 PM1/15/17
to fireba...@googlegroups.com
Usually when users upload photos using their phones to firebase storage, it's 3MB sized and I want to serve it in 200x300 size (which is around few hundreds KB).

Is there a way (or there is a plan to support) to serve firebase images with multiple sizes stored in:



In GAE, if the image is stored in blobstore, there is get_serving_url that allows serving the image in any size. It would be a pain to move the images to GAE just to get this functionality.

Felix Halim

James Spivey

unread,
Jan 16, 2017, 4:18:58 PM1/16/17
to Firebase Google Group
Cloudinary service provides a method to resize external resources, you might look into that.

Mike McDonald

unread,
Jan 20, 2017, 12:41:19 PM1/20/17
to Firebase Google Group
Felix,

Because Firebase Storage shares the same bucket at GAE, you don't have to move anything, you can simply use getServingURL() in GAE and things will Just Work™. You're still setting up a thin GAE server with one endpoint to generate those thumbnails, but it's hard to beat the price (free ;).

Eventually, having a built in image resizing API is something we're considering, but it's a decent bit of infrastructure work to create, and with the ease of use on the above, it's hard to justify.

Otherwise, Cloudinary or Imgix are good APIs to do this (see SO post on how).

Thanks,
--Mike

Felix Halim

unread,
Jan 23, 2017, 3:09:16 AM1/23/17
to fireba...@googlegroups.com
Hi Mike,

I tried your first suggestion, however the files produced by Firebase Storage is inaccessible by GAE or gsutil. Thus, I cannot use it to call get_serving_url(). I tried accessing the files using gsutil, I got errors like:

AccessDeniedException: Access denied. Please ensure you have OWNER permission on gs://<my-firebase-storage-bucket>/myobject.

Setting the bucket permissions as owner doesn't help. Setting the object permissions is not allowed (it gives the same error message that I'm not the owner).

How do I set the firebase-storage-uploaded files to be accessible from GAE or gsutil?


FYI, this docs explains how to do it the other way around (you have files produced by GAE and want to be accessed by firebase):

gsutil -m acl ch -r -u firebase...@system.gserviceaccount.com:O gs://<your-firebase-storage-bucket>




--
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/6b42b17a-545e-4963-b837-faedb73560b7%40googlegroups.com.

For more options, visit https://groups.google.com/d/optout.

Kato Richardson

unread,
Jan 24, 2017, 11:55:47 AM1/24/17
to Firebase Google Group
Felix,

If you receive Access denied, then you must not have the appropriate permissions. Most likely, you set your login account to owner, while your script would obviously be using a different service account credential, and you'd need to set that one to get access?

☼, Kato

On Sun, Jan 22, 2017 at 8:59 PM, Felix Halim <felix...@gmail.com> wrote:
Hi Mike,

I tried your first suggestion, however the files produced by Firebase Storage is inaccessible by GAE or gsutil. Thus, I cannot use it to call get_serving_url(). I tried accessing the files using gsutil, I got errors like:

AccessDeniedException: Access denied. Please ensure you have OWNER permission on gs://<my-firebase-storage-bucket>/myobject.

Setting the bucket permissions as owner doesn't help. Setting the object permissions is not allowed (it gives the same error message that I'm not the owner).

How do I set the firebase-storage-uploaded files to be accessible from GAE or gsutil?


FYI, this docs explains how to do it the other way around (you have files produced by GAE and want to be accessed by firebase):

gsutil -m acl ch -r -u firebase-storage@system.gserviceaccount.com:O gs://<your-firebase-storage-bucket>




On Fri, Jan 20, 2017 at 9:41 AM, 'Mike McDonald' via Firebase Google Group <firebase-talk@googlegroups.com> wrote:
Felix,

Because Firebase Storage shares the same bucket at GAE, you don't have to move anything, you can simply use getServingURL() in GAE and things will Just Work™. You're still setting up a thin GAE server with one endpoint to generate those thumbnails, but it's hard to beat the price (free ;).

Eventually, having a built in image resizing API is something we're considering, but it's a decent bit of infrastructure work to create, and with the ease of use on the above, it's hard to justify.

Otherwise, Cloudinary or Imgix are good APIs to do this (see SO post on how).

Thanks,
--Mike


On Sunday, January 15, 2017 at 4:45:13 PM UTC-8, Felix Halim wrote:
Usually when users upload photos using their phones to firebase storage, it's 3MB sized and I want to serve it in 200x300 size (which is around few hundreds KB).

Is there a way (or there is a plan to support) to serve firebase images with multiple sizes stored in:



In GAE, if the image is stored in blobstore, there is get_serving_url that allows serving the image in any size. It would be a pain to move the images to GAE just to get this functionality.

Felix Halim

--
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/6b42b17a-545e-4963-b837-faedb73560b7%40googlegroups.com.

For more options, visit https://groups.google.com/d/optout.

--
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.

For more options, visit https://groups.google.com/d/optout.



--

Kato Richardson | Developer Programs Eng | kato...@google.com | 775-235-8398

Felix Halim

unread,
Jan 25, 2017, 2:33:16 AM1/25/17
to fireba...@googlegroups.com
Hi Kato,

The file is created via firebase using:


Who is the owner of that file? 


I can't even view the metadata in the storage browser due to permission error.
I don't think I can login as firebase...@system.gserviceaccount.com



On Tue, Jan 24, 2017 at 8:55 AM, 'Kato Richardson' via Firebase Google Group <fireba...@googlegroups.com> wrote:
Felix,

If you receive Access denied, then you must not have the appropriate permissions. Most likely, you set your login account to owner, while your script would obviously be using a different service account credential, and you'd need to set that one to get access?

☼, Kato
On Sun, Jan 22, 2017 at 8:59 PM, Felix Halim <felix...@gmail.com> wrote:
Hi Mike,

I tried your first suggestion, however the files produced by Firebase Storage is inaccessible by GAE or gsutil. Thus, I cannot use it to call get_serving_url(). I tried accessing the files using gsutil, I got errors like:

AccessDeniedException: Access denied. Please ensure you have OWNER permission on gs://<my-firebase-storage-bucket>/myobject.

Setting the bucket permissions as owner doesn't help. Setting the object permissions is not allowed (it gives the same error message that I'm not the owner).

How do I set the firebase-storage-uploaded files to be accessible from GAE or gsutil?


FYI, this docs explains how to do it the other way around (you have files produced by GAE and want to be accessed by firebase):

gsutil -m acl ch -r -u firebase...@system.gserviceaccount.com:O gs://<your-firebase-storage-bucket>



Felix Halim

unread,
Jan 25, 2017, 6:21:22 AM1/25/17
to fireba...@googlegroups.com
I found a solution to my problem.

So the "object default permissions" of the <project>.appspot.com bucket has only firebase...@system.gserviceaccount.com as the owner (by default).

This makes all objects unreadable by other accounts. By adding my own account using "Edit object default permissions" of the bucket (via storage browser), now all objects written in that bucket by firebase...@system.gserviceaccount.com is also owned by my account as well and I can read it using gsutil.

I'm also able to get the get_serving_url working using GAE, accessing the objects in the bucket directly:

from google.appengine.api import app_identity
from google.appengine.ext import blobstore

...

        bucket = app_identity.get_default_gcs_bucket_name()
        filename = '/{}/path/to/the/object/file'.format(bucket)
        blobstore_filename = '/gs{}'.format(filename)
        blob_key = blobstore.create_gs_key(blobstore_filename)
        data = get_serving_url(blob_key, size=0)
        self.response.headers['Content-Type'] = 'text/plain'
        self.response.write(data)





On Tue, Jan 24, 2017 at 11:12 PM, Felix Halim <felix...@gmail.com> wrote:
Hi Kato,

The file is created via firebase using:


Who is the owner of that file? 


I can't even view the metadata in the storage browser due to permission error.
I don't think I can login as firebase-storage@system.gserviceaccount.com


Reply all
Reply to author
Forward
0 new messages