librelist archives

« back to archive

Passing file uploads in forms

Passing file uploads in forms

From:
Owein Reese
Date:
2012-12-15 @ 19:55
I've got a form which contains a file that I'm trying to pass on to
Cloudinary but am running into trouble. When using Requests that keeps
returning a 500 error. I've stripped it down to just the file itself but
still am having no luck.

Either I'm accessing the werkzeug FileStorage object wrong or I'm accessing
their API wrong. Here's my gist:

https://gist.github.com/4298659

Anyone see anything obvious, otherwise I'll turn to them for help. And, no,
I'm not using their library because it's designed for Django...

Thanks much in advance.

Re: [flask] Passing file uploads in forms

From:
Steven Kryskalla
Date:
2012-12-15 @ 22:13
On Sat, Dec 15, 2012 at 11:55 AM, Owein Reese <owreese@gmail.com> wrote:
> Either I'm accessing the werkzeug FileStorage object wrong or I'm accessing
> their API wrong. Here's my gist:
>
> https://gist.github.com/4298659
>
> Anyone see anything obvious, otherwise I'll turn to them for help. And, no,
> I'm not using their library because it's designed for Django...

Your implementation of their API is not correct. You're confusing the
API key with the API secret. The code for parsing "config" throws away
the API key, which is needed to make a request.

Even if the python API they provide integrates with django, their code
is still usable with any framework. This is working for me:
https://gist.github.com/4299726
http://res.cloudinary.com/ummwut/image/upload/v1355609131/999.jpg ;)

Two other tips:
1. try not to mix tabs and spaces, your gist wouldn't run for me
because the indentation was inconsistent, I had to reindent it
2. if you post code, try to include all the code for a minimally working example

-Steve

Re: [flask] Passing file uploads in forms

From:
Owein Reese
Date:
2012-12-15 @ 22:38
Thanks Steve. I reached out to them and got guidance. Problem was that I
was not loading up the config in my dev environment. Simple and stupid.
Just the way I like all my mistakes.

As far as the indentation, trying out Ninja IDE. Fighting it with my
preferred indentation (2) instead of the recommended (4.)


On Sat, Dec 15, 2012 at 2:13 PM, Steven Kryskalla <skryskalla@gmail.com>wrote:

> On Sat, Dec 15, 2012 at 11:55 AM, Owein Reese <owreese@gmail.com> wrote:
> > Either I'm accessing the werkzeug FileStorage object wrong or I'm
> accessing
> > their API wrong. Here's my gist:
> >
> > https://gist.github.com/4298659
> >
> > Anyone see anything obvious, otherwise I'll turn to them for help. And,
> no,
> > I'm not using their library because it's designed for Django...
>
> Your implementation of their API is not correct. You're confusing the
> API key with the API secret. The code for parsing "config" throws away
> the API key, which is needed to make a request.
>
> Even if the python API they provide integrates with django, their code
> is still usable with any framework. This is working for me:
> https://gist.github.com/4299726
> http://res.cloudinary.com/ummwut/image/upload/v1355609131/999.jpg ;)
>
> Two other tips:
> 1. try not to mix tabs and spaces, your gist wouldn't run for me
> because the indentation was inconsistent, I had to reindent it
> 2. if you post code, try to include all the code for a minimally working
> example
>
> -Steve
>

Re: [flask] Passing file uploads in forms

From:
Simon Zimmermann
Date:
2012-12-15 @ 21:26
On Sat, Dec 15, 2012 at 8:55 PM, Owein Reese <owreese@gmail.com> wrote:
> Either I'm accessing the werkzeug FileStorage object wrong or I'm accessing
> their API wrong.

Yes, Files are not attached to the `request.form` MultiDict, but
instead in the files attribute.

http://flask.pocoo.org/docs/api/#flask.Request.files
http://flask.pocoo.org/docs/patterns/fileuploads/

Re: [flask] Passing file uploads in forms

From:
kracekumar ramaraju
Date:
2012-12-15 @ 20:23
On a quick scan  reveals you haven't tried flask-uploads, mind trying it
http://flask.pocoo.org/docs/patterns/fileuploads/ ?.

On Sun, Dec 16, 2012 at 1:25 AM, Owein Reese <owreese@gmail.com> wrote:

> I've got a form which contains a file that I'm trying to pass on to
> Cloudinary but am running into trouble. When using Requests that keeps
> returning a 500 error. I've stripped it down to just the file itself but
> still am having no luck.
>
> Either I'm accessing the werkzeug FileStorage object wrong or I'm
> accessing their API wrong. Here's my gist:
>
> https://gist.github.com/4298659
>
> Anyone see anything obvious, otherwise I'll turn to them for help. And,
> no, I'm not using their library because it's designed for Django...
>
> Thanks much in advance.
>



-- 
*
Thanks & Regards

"Talk is cheap, show me the code" -- Linus Torvalds
kracekumar
www.kracekumar.com
*

Re: [flask] Passing file uploads in forms

From:
Owein Reese
Date:
2012-12-15 @ 20:28
Id use that if it didn't assume you were downloading to the file system.
I'm not.
On Dec 15, 2012 3:27 PM, "kracekumar ramaraju" <kracethekingmaker@gmail.com>
wrote:

> On a quick scan  reveals you haven't tried flask-uploads, mind trying it
> http://flask.pocoo.org/docs/patterns/fileuploads/ ?.
>
> On Sun, Dec 16, 2012 at 1:25 AM, Owein Reese <owreese@gmail.com> wrote:
>
>> I've got a form which contains a file that I'm trying to pass on to
>> Cloudinary but am running into trouble. When using Requests that keeps
>> returning a 500 error. I've stripped it down to just the file itself but
>> still am having no luck.
>>
>> Either I'm accessing the werkzeug FileStorage object wrong or I'm
>> accessing their API wrong. Here's my gist:
>>
>> https://gist.github.com/4298659
>>
>> Anyone see anything obvious, otherwise I'll turn to them for help. And,
>> no, I'm not using their library because it's designed for Django...
>>
>> Thanks much in advance.
>>
>
>
>
> --
> *
> Thanks & Regards
>
> "Talk is cheap, show me the code" -- Linus Torvalds
> kracekumar
> www.kracekumar.com
> *
>

Re: [flask] Passing file uploads in forms

From:
kracekumar ramaraju
Date:
2012-12-15 @ 20:24
Sorry, correct url is http://packages.python.org/Flask-Uploads/

On Sun, Dec 16, 2012 at 1:53 AM, kracekumar ramaraju <
kracethekingmaker@gmail.com> wrote:

> On a quick scan  reveals you haven't tried flask-uploads, mind trying it
> http://flask.pocoo.org/docs/patterns/fileuploads/ ?.
>
> On Sun, Dec 16, 2012 at 1:25 AM, Owein Reese <owreese@gmail.com> wrote:
>
>> I've got a form which contains a file that I'm trying to pass on to
>> Cloudinary but am running into trouble. When using Requests that keeps
>> returning a 500 error. I've stripped it down to just the file itself but
>> still am having no luck.
>>
>> Either I'm accessing the werkzeug FileStorage object wrong or I'm
>> accessing their API wrong. Here's my gist:
>>
>> https://gist.github.com/4298659
>>
>> Anyone see anything obvious, otherwise I'll turn to them for help. And,
>> no, I'm not using their library because it's designed for Django...
>>
>> Thanks much in advance.
>>
>
>
>
> --
> *
> Thanks & Regards
>
> "Talk is cheap, show me the code" -- Linus Torvalds
> kracekumar
> www.kracekumar.com
> *
>



-- 
*
Thanks & Regards

"Talk is cheap, show me the code" -- Linus Torvalds
kracekumar
www.kracekumar.com
*