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>
1
  • Why are you storing the blob key as a string? There's a BlobRefProperty specifically for this purpose. Commented Mar 28, 2011 at 23:57

1 Answer 1

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.

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

3 Comments

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..
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
"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?

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.