changeset 33:00e12392f8d4

Fix saving uploaded form file to a temporary file The file must be saved to a temporary file for conversion via pyuno. pyuno can only accept filenames. Also the file position must be reset to the start. If the position is not reset we will get a IllegalArgumentException: Unsupported URL from pyuno when converting a file without template rendering.
author Björn Ricks <bjoern.ricks@intevation.de>
date Thu, 16 Oct 2014 11:45:51 +0200
parents e6f2f1481de2
children 89ffa12bd48d
files odfcast/convert.py
diffstat 1 files changed, 2 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/odfcast/convert.py	Thu Oct 16 11:35:47 2014 +0200
+++ b/odfcast/convert.py	Thu Oct 16 11:45:51 2014 +0200
@@ -78,9 +78,10 @@
         return render_template("convert.html")
 
     def save_form_file(self, infile):
-        outfile = tempfile.TemporaryFile()
+        outfile = tempfile.NamedTemporaryFile()
         infile.save(outfile)
         infile.close()
+        outfile.seek(0)
         return outfile
 
     def convert(self, infile, fformat):
This site is hosted by Intevation GmbH (Datenschutzerklärung und Impressum | Privacy Policy and Imprint)