Upload Files with Ferris 3

64 views
Skip to first unread message

Daniel Arita

unread,
Jan 19, 2015, 4:08:41 PM1/19/15
to ferris-f...@googlegroups.com
Hi,

I was using the new version of Ferris (Ferris 3) since it is easier to create and API with the "hvild". One of the things we managed with the previous version of Ferris was the upload of files, with the new version since all the requests are made through AJAX sending the file always gives an error. To achieve this I have a method that first return the url for the upload and then doing a POST through AJAX to that url. This always gives the following error:

ValueError("No JSON object could be decoded")

What is the best way to upload files using the new structure from Ferris.

Thanks in advance for the help,

Jon Wayne Parrott

unread,
Jan 20, 2015, 8:54:22 PM1/20/15
to Daniel Arita, ferris-framework
Hi Daniel,
It seems the consensus in the cloud platform community is to create a separate handler for this all together. So, for example:
  • You'd have an endpoint that returns a generated blobstore upload URL that sets the callback to a regular webapp2 handler.
  • You'd create the webapp2 handler to operate as the callback logic when the upload is successful.
Not the prettiest solution, but it's manageable. Let me know if you need any more assistance here.

 

Daniel Arita

unread,
Jan 21, 2015, 9:56:11 AM1/21/15
to ferris-f...@googlegroups.com, daniel...@gmail.com
Thanks Jon! I will try creating the Handler and let you know how things turn out.

Aki Tanaka

unread,
Sep 14, 2015, 2:49:41 PM9/14/15
to Ferris Framework, jonathan...@cloudsherpas.com

Dear Sir,

I am getting the same problem as Daniel. I wonder if you could spend some hours to make an example for us?
Thank you so much.

My current solution is:
1. On client side: Decode image to base64 string
2. Use hvild to send decoded image String as normal
3. On server side: Convert string to image.
4. Save image on Google Cloud Storage and retrieve an URL.
5. Save Url on datastore.

Could you please advise if this method could work or not?

Ben Adrian Sarmiento

unread,
Sep 15, 2015, 3:52:30 PM9/15/15
to Ferris Framework
I'm sorry but I'll be honest to you: this solution is worse than having separate handlers.

I agree with Jon's solution here though, it's ugly but this is a "standard":

You will create two handlers for your app that you'll specify in app.yaml:
  • First is the file upload handler using webapp2 or any other framework that is not limited to parsing Json out of request bodies
  • The 2nd one is for your Json Rest Api (This has to be 2nd as this is usually your wildcard url handler)
Reply all
Reply to author
Forward
0 new messages