Below is a tested python example showing how to write a JPEG to both GCS 
using the "new" API and Blobstore.  Note how VERY similar the process is 
(all things considered).  IMO Google did a terrific job making this 
inevitable transition mostly seamless.  The only possible prerequisite 
setup required is to add your GAE service account name as a team member in 
the Google APIs console where you enable/manage the Cloud Storage 
service... as described in step #5 here: 
https://developers.google.com/appengine/docs/python/googlestorage/

Note: Both examples below assume "img_data" contains JPEG image data such 
as from
an images service transformation
    
#----------------------------------------------------------
# GCS image write & serving url
# Assumes: import cloudstorage as gcs
#----------------------------------------------------------

GCS_NAME_CHARS = string.ascii_letters + string.digits
rand = random.SystemRandom()
gcs_bucketname = '/yourbucket/'

# Create a random 32 char GCS filename
gcs_objectname = ''.join([rand.choice(GCS_NAME_CHARS) for _ in range(32)])

# Create and write the image data to the GCS object
gcs_fullname = gcs_bucketname + gcs_objectname
with gcs.open(gcs_fullname, 'w', content_type='image/jpeg') as gcs_file:
    gcs_file.write(img_data)
gcs_file.close()

gcs_key = blobstore.create_gs_key('/gs' + gcs_fullname)
serving_url = images.get_serving_url(gcs_key)

#----------------------------------------------------------
# Blobstore image write & serving url
#----------------------------------------------------------

# Create and write the image data to the blobstore file
bs_filename = files.blobstore.create(mime_type='image/jpeg')
with files.open(bs_filename, 'a') as bs_file:
    bs_file.write(img_data)
files.finalize(bs_filename)

# Get the serving url
blob_key = files.blobstore.get_blob_key(bs_filename)
serving_url = images.get_serving_url(blob_key)


On Tuesday, June 4, 2013 2:46:22 PM UTC-4, Richmond Manzana wrote:
>
> Hello Again Everyone!
>
> We've been busy since I/O!
>
> Pre-release SDKs for Python and Java here:
> http://code.google.com/p/**googleappengine/downloads/list<http://code.google.com/p/googleappengine/downloads/list>
>
> Please see the pre-release notes below.
>
> Cheers,
> Richmond Manzana
>
>
> App Engine Python SDK - Pre-Release Notes
>
> Version 1.8.1
> ===============================
> - The Task Queue async API is now a GA feature. The asynchronous methods
>   improve utilization by allowing your app to add, lease and delete 
> multiple
>   tasks in parallel.
> - Cloud Console projects are now created by default whenever a new App 
> Engine
>   app is created.  This is a Preview feature.
> - The Experimental Files API has been deprecated in favor of the Google 
> Cloud
>   Storage library, now available as a Preview feature.
> - Bandwidth between App Engine and Google Cloud Storage is currently free 
> of
>   charge (this may change in the future for certain levels of service).
> - The Search API has graduated from Experimental to Preview. Apps that have
>   billing enabled can exceed the free quota levels and will be charged for
>   usage above these levels.
> - Estimated number of search results will only be accurate if <= the 
> number of
>   results requested. By default this can be overridden by setting
>   number_found_accuracy QueryOption in the Search API.
> - Dates, atoms, and number fields can now be found by searching without a 
> field
>   restriction in the Search API.
> - A quoted empty string now returns atom fields with empty values for the
>   Search API.
> - Snippet and count functions are no longer allowed in sort expressions 
> for the
>   Search API.
> - The Search API now has improved error messages for user errors and 
> internal
>   errors.
> - The Datastore now assigns scattered auto ids by default. Legacy auto ids
>   are still available via the 'auto_id_policy' option in app.yaml.
> - The Sockets API now allows client code to call get/set options against
>   sockets. Previously, calls raised "Not Implemented" exceptions. For 
> supported
>   options, calls to getsockopt will return a mock value and calls to 
> setsockopt
>   will be silently ignored.  Errors will continue to be raised for 
> unsupported
>   options. The currently supported options are: SO_KEEPALIVE, SO_DEBUG,
>   TCP_NODELAY, SO_LINGER, SO_OOBINLINE, SO_SNDBUF, SO_RCVBUF, and 
> SO_REUSEADDR.
> - The ndb library now supports distinct queries. This is a Preview feature.
>     
> https://code.google.com/p/appengine-ndb-experiment/issues/detail?id=229
>
>
> App Engine Java SDK - Pre-Release Notes
>
> Version 1.8.1
> =============
> - This SDK will be the last release that can deploy Java 6 apps. In 1.8.2,
>   the SDK will only be compiled with the Java 7 compiler and the only 
> target
>   runtime will be Java 7.
> - The Task Queue async API is now a GA feature. The asynchronous methods
>   improve utilization by allowing your app to add, lease and delete 
> multiple
>   tasks in parallel.
> - Cloud Console projects are now created by default whenever a new App 
> Engine
>   app is created.  This is a Preview feature.
> - The Experimental Files API has been deprecated in favor of the Google 
> Cloud
>   Storage library, now available as a Preview feature.
> - Bandwidth between App Engine and Google Cloud Storage is currently free 
> of
>   charge (this may change in the future for certain levels of service).
> - The Search API has graduated from Experimental to Preview. Apps that have
>   billing enabled can exceed the free quota levels and will be charged for
>   usage above these levels.
> - Estimated number of search results will only be accurate if <= the 
> number of
>   results requested. By default this can be overridden by setting X in the
>   Search API.
> - Dates, atoms, and number fields can now be found by searching without a 
> field
>   restriction in the Search API.
> - A quoted empty string now returns atom fields with empty values for the
>   Search API.
> - Snippet and count functions are no longer allowed in sort expressions 
> for the
>   Search API.
> - The Search API now has improved error messages for user errors and 
> internal
>   errors.
> - The Datastore now assigns scattered auto ids by default. Legacy auto ids
>   are still available via the 'auto_id_policy' option in appengine-web.xml.
> - The Sockets API now allows client code to call get/set options against
>   sockets. Previously, calls raised "Not Implemented" exceptions. When
>   java.net.Socket.get<option>() is called, a mock value is returned, calls 
> to
>   set<option>() will be silently ignored.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Google App Engine" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to google-appengine+unsubscr...@googlegroups.com.
To post to this group, send email to google-appengine@googlegroups.com.
Visit this group at http://groups.google.com/group/google-appengine?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to