0

I converted nicks blog example to ndb now this line fails:

self.send_blob(file_info.blob, save_as=True) 

with this error:

ValueError: Expected BlobInfo value for blob_key_or_info.

Rest of the class:

class FileDownloadHandler(blobstore_handlers.BlobstoreDownloadHandler):
   def get(self, file_id):
       file_info = models.FileInfo.get_by_id(long(file_id))

if not file_info or not file_info.blob:
  self.error(404)
  return

self.send_blob(file_info.blob)
#self.send_blob(file_info.blob, save_as=True)

Why did the result change?

mechanical_meat
  • 163,903
  • 24
  • 228
  • 223

1 Answers1

1

In NDB you have to use a ndb.BlobKeyProperty() to hold the blobkey.

To use it :

class FileInfo(ndb.Model):     
    ....
    blob_ref = ndb.BlobKeyProperty() 
....

file_info = models.FileInfo.get_by_id(... key_name ....)
self.send_blob(blobstore.BlobInfo.get(file_info.blob_ref), save_as=True)
voscausa
  • 11,253
  • 2
  • 39
  • 67
  • Thanks, that works, I just needed to change the send_blob (I had already converted the blob reference to ndb) self.send_blob(blobstore.BlobInfo.get(file_info.blob), save_as=True) –  Feb 26 '13 at 17:20