Hello,

I have a simple CGI uploader script, which I and some of my friends are
using to share (often big) files in private server.  Recently I decided
to rewrite it using Pylons to utilize more fancy stuff like automatic
file list refresh and sorting without reloading page (and all the other
AJAX niceness), but first there's one big obstacle to solve: right now
when uploading files, they're put in /tmp ─ and that's bad for the huge
files, because partition which is mounted on /tmp isn't that big.  Also
there's some overhead when files are copied from /tmp to the final
location into another partition.

In my CGI script I subclass cgi.FieldStorage and override it's method
make_file():

  class MyFieldStorage(cgi.FieldStorage):
      def make_file(self, binary=None):
          import tempfile
          return tempfile.NamedTemporaryFile(dir=TMP_DIR)

(where TMP_DIR is '~/tmp' or something similar.)  Then I can easily move
uploaded file to directory which is viewable from the web.

I tried to do the same in Pylons using this example with version 0.9.6.2:
http://wiki.pylonshq.com/display/pylonscookbook/Hacking+Pylons+for+handling+large+file+upload

Unfortunately, it doesn't work (it seems like the changes are ignored or
something is overtaking them).  Maybe I made a mistake somewhere, but
right now I can't find anything wrong.

So is there another way to solve this problem?  Any ideas are welcome.

-- 
Audrius Kažukauskas

Attachment: pgpE3qBmwFD8t.pgp
Description: PGP signature

Reply via email to