Using Blobstore Python API over HTTPS generates 405 error when redirecting back

Don't know if it's I'm doing it wrong or if there's a bug (I would think so, seen others having the same problem) in the blobstore.create_upload_url method.

In my app.yaml I have for some url's the property secure: always and the action attribute of the form element starts with https:// but when it's return from the API it's redirected to non-https.

There's a bug file on google app engine issue tracker but no response from google.

Does anyone know of a good work around? My current solution is to have a separate .py file to handle the response and then direct back to the original url but over https.

EDIT

I use this to set the action attribute:

from google.appengine.api import blobstore
view['upload_url'] = blobstore.create_upload_url 
## pass the view dict to template and in template

<form action="{{ upload_url }}" enctype="multipart/form-data" method="post">
</form>

The output in the html looks something like:

action="https://appid.appspot.com/_ah/upload/AMmfu6bcA9Sfz5isqw6PNNB8xzRy2rUoLaMS2GFjfPEwCZ-vg9M_hQTOR87wYdnMo7ZIbQX9NiNjORFTiKaUoLMHRpXvPf6r8Y5963GD9Cbv_9gIKgtEmtdvt5VcvQxzvbegqG3V5xQT/ALBNUaYAAAAATPdfcxxACFrQnUiLXWx61ViMDZ7F0aLF/"

The file uploads (I can view it in admin console->blob viewer) but when the API redirect back it redirects http and when using secure: always a http request returns a HTTP 405 error.

This is the upload handler:

class AddUpdateImageStore(blobstore_handlers.BlobstoreUploadHandler):
def post(self):
    if self.request.get('imagestore_key'):
        image = dbImageStore.ImageStore.get(self.request.get('imagestore_key'))
    else:
        image = dbImageStore.ImageStore()

    image.name = self.request.get('image_name')

    upload_files =  self.get_uploads('image_file')

    if upload_files:
        image.imageUrl = images.get_serving_url(str(upload_files[0].key()))

    imageKey = db.put(image)

    for language in Settings.languages:
        description = self.request.get('image_description_' + language)
        if description:
            imageDescription = dbImageStore.ImageDescription.gql('WHERE imageEntry = :imageEntry AND lang = :lang', imageEntry = imageKey, lang = language).get()
            if imageDescription is None:
                imageDescription = dbImageStore.ImageDescription()
                imageDescription.imageEntry = imageKey
                imageDescription.lang = language

            imageDescription.description = description
            db.put(imageDescription)

    self.redirect('/edit/imageStore/?status=1&message=Image added/updated')

Answers


This issue has been fixed by SDK 1.4.2. I just tested it and it is working fine now.

See issue in tracker here: http://code.google.com/p/googleappengine/issues/detail?id=3463


Need Your Help

Slow stored procedure

sql sql-server networking stored-procedures

I currently have a stored procedure that copies content from one table to another.

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.