Reputation: 2480
In my GAE app I want to store the uploaded file in a ndb.BlobProperty . How can I assign the uploaded file content to this property.
Further more is BlobProperty the standard approach to store user uploaded files.
Upvotes: 0
Views: 371
Reputation:
Simply put, assign a serving url that you pass to a handler setup by routes
handlers
class GetBlobstoreUrl(BaseHandler):
def get(self):
upload_url = blobstore.create_upload_url('/upload/')
self.response.out.write(upload_url)
class UploadHandler(blobstore_handlers.BlobstoreUploadHandler):
def post(self):
upload_files = self.get_uploads()
blob_info = upload_files[0]
model
class SomeModel(ndb.Model):
avatar = ndb.BlobProperty()
Upvotes: 1