0
votes

I am using the blobstore to upload and download files in the python version of Google App Engine. I understand how to write objects to the blobstore line-by-line and I understand how to POST and download a blobstore item, but how do I read data back out of the blobstore line-by-line if all I have is the blobstore key?

file_name = files.blobstore.create(mime_type='application/octet-stream')

with files.open(file_name, 'a') as f:
    f.write("data")

files.finalize(file_name)
# Get the file's blob key
blob_key = files.blobstore.get_blob_key(file_name)

#starting with the blob_key, read from the blobstore line-by-line.
# ???
#with files.open() as f:
#foo = f.read()
1

1 Answers

3
votes

I think you need the blob reader. Here is an example of use:

from google.appengine.ext import blobstore

blob_reader = blobstore.BlobReader(blob_key)
for line in blob_reader:
    process_line(line)