0

I currently have a python-based GAE site that has a signup form where users can input account details along with a profile image to register. Based on suggestions from SO, I'm going with a mix of datastore and blobstore so it seems that this would require a simultaneous datastore put and a blobstore upload

However, from the google docs and the sample code I've been able to get running, it looks like the blobstore upload requires a redirect to a separate upload handler which conflicts with the datastore post handler (part of the current form handler)

Have been primarily referencing the following example for blobstore: https://cloud.google.com/appengine/docs/python/blobstore/#Python_Uploading_a_blob

Wanted to see what is the best way to handle this type of setup? I assume this would be quite a common form of usage... any sample code would be very helpful!

3
  • 2
    Checkout this question stackoverflow.com/questions/17294507/… but better try to use Cloud Storage. Commented Oct 2, 2014 at 12:54
  • As far as I understand your use case, user data and a reference to an image will be stored in Datastore. You will not have the reference before an image is stored, so upload handler is a way to go, but +1 Dmitry - use GCS. Commented Oct 2, 2014 at 13:06
  • Thanks, will look into GCS as well. Is it preferred because blobstore is expected to be phased out? Commented Oct 2, 2014 at 13:34

1 Answer 1

1

Yes, this is straightforward to do.

On your web page, you have a form that a user can use to submit a profile image. You can have other form elements in this form and post this other data as well (user name, etc.) as well as the image.

In your blobstore upload handler, you receive all of the form data -- the image and any other form elements that you have. The blobstore upload handler can call a put to add data to the datastore in addition to storing the file in the blobstore.

Sign up to request clarification or add additional context in comments.

1 Comment

Thanks, have gotten it to work with your solution. Actually found a good reference in the app engine docs for blobstore handlers: cloud.google.com/appengine/docs/python/tools/webapp/…

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.