Skip to content

Instantly share code, notes, and snippets.

@mentat
Created October 27, 2011 22:50
Show Gist options
  • Save mentat/1321137 to your computer and use it in GitHub Desktop.
Save mentat/1321137 to your computer and use it in GitHub Desktop.
Some helpful handlers for downloading blobs.
class BlobMigrationHandler(YourCustomHandler):
" List out the blob keys so we can migrate them. "
def get(self):
CHUNK = 300
cursor = self.request.GET.get('cursor')
q = blobstore.BlobInfo.all()
if cursor:
q.with_cursor(cursor)
data = {
'blobkeys': [dict(key=str(x.key())) for x in q.fetch(CHUNK)],
'cursor':str(q.cursor())
}
self.respond_json(data)
class BlobDownloadHandler(blobstore_handlers.BlobstoreDownloadHandler):
" Dumb download handler. Only using for migration. "
def get(self, resource):
resource = str(urllib.unquote(resource))
blob_info = blobstore.BlobInfo.get(resource)
self.send_blob(blob_info)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment