upload images into google app engine

325 views
Skip to first unread message

hitesh jain

unread,
Mar 10, 2014, 4:09:31 AM3/10/14
to objectify...@googlegroups.com
Hi,

I am making an restful call to my application which is deployed in google app engine. I pass in the image url to the http request. I want to fetch the image content from the URL and store the byte data into appengine. To fetch the image data I can use
URLFetchService. 

To store the image data which can be more than 1 mb what is the best way to do that? In this datastore entity I think I can
store only 1MB byte array.
Once image is stored then I want to get the url of that image so that it can be accessed later on anytime.

I have seen google blob store service but that expects HttpRequest as input parameter and I will have to use the
httpclient api to create a POST request and submit to the
upload url as generated blobstoreService.createUploadUrl("/upload")

Is there any other better way to do this?

Jeff Schnitzer

unread,
Mar 10, 2014, 4:35:24 AM3/10/14
to objectify...@googlegroups.com
We write image data to the blobstore with the Files API:

https://developers.google.com/appengine/docs/java/blobstore/#Java_Writing_files_to_the_Blobstore

We're still watching to see what Google is going to do with this api
and the blobstore, but for now it works.

Jeff
> --
> You received this message because you are subscribed to the Google Groups
> "objectify-appengine" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to objectify-appen...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.

Andy Dennie

unread,
Mar 11, 2014, 9:23:48 AM3/11/14
to objectify...@googlegroups.com


On Monday, March 10, 2014 4:09:31 AM UTC-4, hitesh jain wrote:
Hi,

I am making an restful call to my application which is deployed in google app engine. I pass in the image url to the http request. I want to fetch the image content from the URL and store the byte data into appengine. To fetch the image data I can use
URLFetchService. 

To store the image data which can be more than 1 mb what is the best way to do that? In this datastore entity I think I can
store only 1MB byte array.
Once image is stored then I want to get the url of that image so that it can be accessed later on anytime.

[...] 
Is there any other better way to do this?

I've taken an approach where I write the image file to GCS, store its bucket name and file name in a datastore entity, and then either serve it directly from GCS or from the ImagesService's getServingUrl (the latter if the client wants any transformations applied first).  I encapsulate the storage mechanism by having the client access a URL specific to my service first (e.g. /myservice/images/12345), and then redirecting to the appropriate serving URL. 

-Andy
Reply all
Reply to author
Forward
0 new messages