| Index: app/handlers/cloud_storage.py
|
| diff --git a/app/handlers/cloud_storage.py b/app/handlers/cloud_storage.py
|
| index 5ca93213d8dbaaac4bd76fb4fb2457542fb59858..7e1dc92f8b6bc70c322c6ac9dec3294cb1248502 100644
|
| --- a/app/handlers/cloud_storage.py
|
| +++ b/app/handlers/cloud_storage.py
|
| @@ -22,6 +22,8 @@ from google.appengine.api import urlfetch
|
|
|
| from models.private_key import PrivateKey
|
|
|
| +import cloudstorage
|
| +
|
| # The Google Cloud Storage bucket for this app
|
| _BUCKET = "pub.dartlang.org"
|
|
|
| @@ -217,6 +219,10 @@ def open(obj):
|
| """Opens an object in cloud storage."""
|
| return files.open(_appengine_object_path(obj), 'r')
|
|
|
| +def open_with_gcs(obj):
|
| + """Opens an object in cloud storage with the GCS library."""
|
| + return cloudstorage.open(_gcs_appengine_object_path(obj), 'r')
|
| +
|
| def read(obj):
|
| """Consumes and returns all data in an object in cloud storage.
|
|
|
| @@ -226,7 +232,7 @@ def read(obj):
|
| This can be necessary since many operations on the file object itself
|
| require a network round trip."""
|
|
|
| - with open(obj) as f:
|
| + with open_with_gcs(obj) as f:
|
| io = StringIO()
|
| data = f.read(_CHUNK_SIZE)
|
| while data:
|
| @@ -252,6 +258,10 @@ def _appengine_object_path(obj):
|
| """Returns the path for an object for use with the AppEngine APIs."""
|
| return '/gs/' + _object_path(obj)
|
|
|
| +def _gcs_appengine_object_path(obj):
|
| + """Returns the path for an object for use with the GCS APIs."""
|
| + return '/' + _object_path(obj)
|
| +
|
| def _iso8601(secs):
|
| """Returns the ISO8601 representation of the given time.
|
|
|
|
|