need for a simpler way to determine upload size is the main reason I
decided to use quixote 1.x instead 2-alpha when our site (douban.com)
was launched in march 2005. today we're still with 1.x.
by the way, talking about current state of Quixote, douban.com is now
getting 450,000 page views a day. 100% dynamically generated by qx. I
might be wrong but, it seems we are a busier site than every other
known ROR/django/TG installations in the world.
at least i'm reporting in as one happy user.
- Bo
On Mar 8, 2006, at 8:34 AM, Mike Orr wrote:
On 3/7/06, Tom Lesters <[EMAIL PROTECTED]> wrote:
Hi All,
Seems upload binary files should be really easy in Quixote,
There are Upload class,
But I could not find how to receive, save file in the demo
Look at the source code, seem it's more about txt file.
the example on quixote cookbook is out dated: there is no
tmp_filename
anymore:
http://www.quixote..ca/qx/UploadingFiles
def count (request):
upload = request.get_field('file')
lines = 0
for line in open(upload.tmp_filename, 'r'):
lines += 1
return "<p>The file is %i lines long." % lines
Anybody can point to me 3-5 line code of checking the binary file
size then
save it ?
To get the file size from a file widget value ('upload' variable):
pos = upload.fp.tell() # Save current position in file.
upload.fp.seek(0, 2) # Go to end of file.
size = upload.fp.tell() # Get new position (which is
the file size).
upload.fp.seek(pos, 0) # Return to previous position.
upload.size = size
if size > max_size:
msg = "The uploaded file is too big (size=%s, max=%
s bytes)"
msg %= (size, max_size)
raise QueryError(msg)
I've proposed having the Quixote set the size as 'upload.size' for
this purpose, but it hasn't been implemented.
Then to save the upload in a file:
f = open(DEST_FILENAME, 'wb')
# Copy file in chunks to avoid using lots of memory.
while 1:
chunk = upload.read(1024 * 1024)
if not chunk:
break
out.write(chunk)
out.close()
upload.close()
--
Mike Orr <[EMAIL PROTECTED]>
([EMAIL PROTECTED] address is semi-reliable)
_______________________________________________
Quixote-users mailing list
Quixote-users@mems-exchange.org
http://mail.mems-exchange.org/mailman/listinfo/quixote-users
_______________________________________________
Quixote-users mailing list
Quixote-users@mems-exchange.org
http://mail.mems-exchange.org/mailman/listinfo/quixote-users