Created
October 27, 2011 22:50
-
-
Save mentat/1321137 to your computer and use it in GitHub Desktop.
Some helpful handlers for downloading blobs.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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