This is how i do it using generator. Its better because it doesn't load the whole file into memory.
class DownloadFile(app.page): path="/(users|tenders)/(\d+)/files/(\d+)" def GET(self, obj_type, obj_id, file_id): doc = db.select("files", locals(), where="id=$file_id and obj_type=$obj_type and obj_id=$obj_id", limit=1)[0] web.header("Content-Disposition", "attachment; filename=%s" % doc.filename) web.header("Content-Type", doc.filetype) web.header('Transfer-Encoding','chunked') f = open(os.path.join(config.upload_dir, doc.path, doc.filename), 'rb') while 1: buf = f.read(1024 * 8) if not buf: break yield buf -- You received this message because you are subscribed to the Google Groups "web.py" group. To post to this group, send email to we...@googlegroups.com. To unsubscribe from this group, send email to webpy+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/webpy?hl=en.