librelist archives

« back to archive

Fwd: Processing files with filename

Fwd: Processing files with filename

From:
Martin Svoboda
Date:
2014-12-07 @ 14:10
Hi, is there any example how to process files in Falcon?
I know that there is an example in tutorial but that does not handle
filenames.

I have tried to parse filename from req.stream when I have send the file
followingly:
http -f POST :9000 file@file.pdf

but then stream contains also other form data and one has to deal with
stream parsing which is not very safe...

Re: [falcon] Fwd: Processing files with filename

From:
Kurt Griffiths
Date:
2014-12-16 @ 00:49
Hi Martin,

You can parse "multipart/form-data" using the cgi module from the standard
library. Here is a gist (not tested!) demonstrating how it might be done:

https://gist.github.com/kgriffs/fe371bfbb2d63211889b

Personally, I think it would be a good idea to include support for this in
Talons<https://github.com/talons/talons>, or directly in falcon.Request. I
added some notes to the bottom of this issue:

https://github.com/racker/falcon/issues/180

Cheers,
Kurt

From: Martin Svoboda <svouloslav@gmail.com<mailto:svouloslav@gmail.com>>
Reply-To: "falcon@librelist.com<mailto:falcon@librelist.com>" 
<falcon@librelist.com<mailto:falcon@librelist.com>>
Date: Sunday, December 7, 2014 at 8:10 AM
To: "falcon@librelist.com<mailto:falcon@librelist.com>" 
<falcon@librelist.com<mailto:falcon@librelist.com>>
Subject: [falcon] Fwd: Processing files with filename



Hi, is there any example how to process files in Falcon?
I know that there is an example in tutorial but that does not handle filenames.

I have tried to parse filename from req.stream when I have send the file 
followingly:
http -f POST :9000 file@file.pdf<mailto:file@file.pdf>

but then stream contains also other form data and one has to deal with 
stream parsing which is not very safe...