Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Here is how I did it. It is more straight forward than you think. Note the following taken from <a href="http://code.google.com/appengine/docs/python/blobstore/overview.html" rel="nofollow">Blobstore overview</a>. <em>"When the Blobstore rewrites the user's request, the MIME parts of the uploaded files have their bodies emptied, and the blob key is added as a MIME part header. <strong>All other form fields and parts are preserved and passed to the upload handler</strong>."</em> In the upload handler is where you can do whatever it is you want with the other form fields. </p> <pre><code> class Topic(db.Model): title = db.StringProperty(multiline=False) blob = blobstore.BlobReferenceProperty() imageurl = db.LinkProperty() class MainHandler(webapp.RequestHandler): def get(self): upload_url = blobstore.create_upload_url('/upload') self.response.out.write('&lt;html&gt;&lt;body&gt;') self.response.out.write('&lt;form action="%s" method="POST" enctype="multipart/form-data"&gt;' % upload_url) self.response.out.write("""Upload File: &lt;input type="file" name="file"&gt;&lt;br&gt; &lt;div&gt;&lt;label&gt;Title:&lt;/label&gt;&lt;/div&gt; &lt;div&gt;&lt;textarea name="title" rows="1" cols="25"&gt;&lt;/textarea&gt;&lt;/div&gt;&lt;input type="submit" name="submit" value="Submit"&gt; &lt;/form&gt;""") self.response.out.write('&lt;br&gt;&lt;br&gt;&lt;h2&gt;TOPIC LIST&lt;/h2&gt;&lt;table border="1"&gt;&lt;tr&gt;&lt;td&gt;') for topic in Topic.all(): self.response.out.write('&lt;div&gt;&lt;img src="%s=s48"/&gt;' % topic.imageurl) self.response.out.write('&lt;div&gt;&lt;b&gt;Image URL: &lt;/b&gt;&lt;i&gt;%s&lt;/i&gt;&lt;/div&gt;' % topic.imageurl) self.response.out.write('&lt;div&gt;&lt;b&gt;Title: &lt;/b&gt;&lt;i&gt;%s&lt;/i&gt;&lt;/div&gt;' % topic.title) self.response.out.write('&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&lt;br&gt;') self.response.out.write('&lt;/body&gt;&lt;/html&gt;') class UploadHandler(blobstore_handlers.BlobstoreUploadHandler): def post(self): upload_files = self.get_uploads('file') # 'file' is file upload field in the form blob_info = upload_files[0] topic = Topic() topic.title = self.request.get("title") topic.blob = blob_info.key() topic.imageurl = images.get_serving_url(str(blob_info.key())) topic.put() self.redirect('/') def main(): application = webapp.WSGIApplication( [('/', MainHandler), ('/upload', UploadHandler), ], debug=True) run_wsgi_app(application) </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload