2

I did everything specified in the documentation of app engine but i couldn't get the blobstore work. Maybe some of you can detect what i am doing wrong. When i clicked the submit button

This kind of a url is seen in the address bar and an empty white page is in front of me.

http://localhost:8080/_ah/upload/agltb2JpbHNvcnVyGwsSFV9fQmxvYlVwbG9hZFNlc3Npb25fXxg9DA

Does anyone have a suggestion?

These are my Handlers :

class MainHandler(webapp.RequestHandler):
  def get(self):
    years = Years.all().order("Year")
    months = Months.all().order("SortNumber")

    upload_url = blobstore.create_upload_url('/imidergi/upload')

    content = {
        'upload': upload_url,
        'yearList':years,
        'monthList':months,
        }

    render_template(self, 'imidergi.html', content)

class AddDergi(blobstore_handlers.BlobstoreUploadHandler):
  def post(self):
    # 'file' is file upload field in the form
    upload_files = self.get_uploads('file')
    blob_info = upload_files[0]

    dergi = Dergiler()
    dergi.Year = self.request.get("yil")
    dergi.Month = self.request.get("ay")
    dergi.DergiPDF = str(blob_info.key())
    dergi.Name = self.request.get("isim")
    dergi.Image = self.request.get("resim")
    dergi.put()

    self.response.out.write(dergi.Name)

And this is the html which renders the form.

<form action="{{ upload }}" method="post" id="dergiform" enctype="multipart/form-data">
  {{ upload }}
  <label>Yil:</label><select name="yil">
  {% for year in yearList %}
    <option value="{{ year.Year }}">{{ year.Year }}</option>
  {% endfor %}
  </select><br/>
  <label>Ay:</label><select name="ay">
  {% for month in monthList %}
    <option value="{{ month.Name }}">{{ month.Name }}</option>
  {% endfor %}
  </select><br/>

  <label>Isim: </label><input type='text' id="isim" name="isim"/><br/>
  <label>Dergi: </label><input type='file' id="file" name="file"/><br/>
  <label>Resim: </label><input type='file' id="resim" name="resim"/><br/>
  <label></label><input type='submit' value='Ekle'/>
</form>
Esteban Küber
  • 36,388
  • 15
  • 79
  • 97
gurkan
  • 3,457
  • 4
  • 25
  • 38

1 Answers1

1

IIRC BlobstoreUploadHandler expects you to return a redirect after you have handled the POST as your handler is really responding to the special BlobStore upload servers and not directly with the client/browser like in a normal request.

Copy the example from the blobstore docs, and remember that you can only respond with headers (like redirects) and not with body content.

Chris Farmiloe
  • 13,935
  • 5
  • 48
  • 57
  • Thank you for your answer but even i have used redirect it still does not work. It would be nice if you can submit some part of code that i have to implement to make it work. Thank you anyway.. – gurkan Mar 28 '11 at 14:07
  • 2
    Can you update your question to reflect your code that returns a redirect and I'll happily take a look. *also please fix your formatting – code needs to be intended with four spaces to show up correctly* – Chris Farmiloe Mar 28 '11 at 14:31
  • "Doesn't work" how? Have you looked at the logs, and have you used the chrome developer tools or firebug to see what is being returned? – Nick Johnson Mar 28 '11 at 23:56