Large File Uploads

88 views
Skip to first unread message

dou...@gmail.com

unread,
May 31, 2007, 8:31:08 AM5/31/07
to web.py
I'm planning a website that needs to allow users to upload files of
essentially arbitrary size.

If the user uploads a large file, can I use something (maybe
threading) to send a response page immediately?

Or does the file have to be fully uploaded before a response can be
generated? Is there a way to upload essentially in the background
while the rest of the page does it's thing? Any suggestions on how to
handle this would be hugely appreciated since I'm pretty much a big
nub.

Regards,

-Dougal

Sutabi

unread,
May 31, 2007, 10:38:37 AM5/31/07
to web.py
This is done on the client-side. Simple use an iframe, and submit the
upload to that iframe (which should be hidden). Use javascript to
handle the submit process and when you load the response page use
javascript to relay the parent page that its done uploading.

dou...@gmail.com

unread,
May 31, 2007, 1:19:03 PM5/31/07
to web.py
Thanks for the response! 2 Follow-up questions, though.

Is there any way to accomodate non-JS enabled browsers? If I use a
regular form-post to another page, the user would definitely need to
wait while the file gets uploaded, right?

-Dougal

bubblboy

unread,
May 31, 2007, 1:54:36 PM5/31/07
to we...@googlegroups.com

This is inherent to the way HTTP POST requests work. When you (as a
browser) want to submit a form through POST, you have to send this to
the server. Only AFTER your request (which is what it is; even a form
submission is a request on the HTTP level) has been received by the
server can it send you a reply. That is HTTP, nothing you can do about
it. This means that if your form is big, you will have to wait for a
long time. Unless you use some javascript tricks, like Sutabi suggested.

For more information, see RFC 2616 [1].

b^4

[1]: http://www.ietf.org/rfc/rfc2616.txt

dou...@gmail.com

unread,
May 31, 2007, 3:11:19 PM5/31/07
to web.py
Thanks a lot guys. That's what I expected, but wanted to make sure.
You've been super-helpful!

Cheers,

-d

On May 31, 3:54 pm, bubblboy <bubbl...@gmail.com> wrote:

Adomas Paltanavičius

unread,
May 31, 2007, 5:05:48 PM5/31/07
to we...@googlegroups.com
Not to mention you can display upload progress, e.g. if using lighttpd
that comes pretty easy: http://trac.lighttpd.net/trac/wiki/Docs:ModUploadProgress

dou...@gmail.com

unread,
Jun 1, 2007, 10:19:46 AM6/1/07
to web.py
I just installed lighttpd on my mac, and I get a 403 - Forbidden error
when I try to access my web.py script.

Could it be a config issue or a permissions issue?

My config file looks vaguely like:

url.rewrite-once = (
"^/dgraham3/favicon.ico$" => "/dgraham3/static/favicon.ico",
"^/dgraham3/static/(.*)$" => "/dgraham3/static/$1",
"^/dgraham3(.*)$" => "/dgraham3/index.py/$1",
)

fastcgi.server = ( ".fcgi" =>
( "localhost" =>
( "min-procs" => 1,
"socket" => "/tmp/fcgi.sock",
"bin-path" => "/Library/WebServer/Documents/dgraham3/
index.py"
)
)
)

On May 31, 7:05 pm, "Adomas Paltanavičius"


<adomas.paltanavic...@gmail.com> wrote:
> Not to mention you can display upload progress, e.g. if using lighttpd
> that comes pretty easy:http://trac.lighttpd.net/trac/wiki/Docs:ModUploadProgress
>

Adomas Paltanavičius

unread,
Jun 1, 2007, 11:16:37 AM6/1/07
to we...@googlegroups.com
A guess would be that maybe you need to use:

fastcgi.server =    ( ".py" =>

...if only the physical file layout is the way I guess.

dou...@gmail.com

unread,
Jun 1, 2007, 11:51:12 AM6/1/07
to web.py
Thanks! The file layout is the way you guessed. Sorry, I should have
mentioned that.

Unfortunately, now the app is being executed, but only sort of. I just
get the words "not found". I don't think it's a server error because
there's no associated error code... I'm hoping you might have an idea
of what might be wrong now, and I'd be happy to provide more info if
you let me know what might help.

Thanks for getting me this far!

-dougal

bubblboy

unread,
Jun 1, 2007, 1:53:13 PM6/1/07
to we...@googlegroups.com

Congratulations: web.py is working. To proceed I recommend you read the
tutorial at [1].

On a side note, let me go out on a leg and speak freely: I suggest you
get yourself more familiar with the HTTP protocol and the difference
between HTTP and HTML if you intend to do serious work with web.py.
Maybe I am mistaking, but from the way you talk about error codes I am
guessing you are not informed about what part of the connection actually
contains the error code and what part is just intended to please humans.
If you have telnet or netcat I recommend you try to play with connecting
those applications to your (or any other HTTP) server on port 80 and
send HTTP headers yourself, such as "GET / HTTP/1.0". The HTTP/1.1 RFC
[2] is the "official" document on the latest version of HTTP. Be aware,
though, that this document is long and tedious (read: boring as hell),
so I recommend a search engine and a query like "how http works".

Good luck and greetings,
b^4

[1]: <http://webpy.infogami.com/tutorial2>
[2]: <http://ietf.org/rfc/rfc2616.txt>

dou...@gmail.com

unread,
Jun 1, 2007, 4:12:50 PM6/1/07
to web.py
Hey, Thanks a lot, and you are absolutely correct, I am unfamiliar
with the HTTP protocol. I didn't quite realise what I was getting into
with web.py, but am glad to be getting the experience. It's something
I ought to learn.

Thanks for the tips and the links, I will be hitting Google.

-dougal

On Jun 1, 3:53 pm, bubblboy <bubbl...@gmail.com> wrote:

Reply all
Reply to author
Forward
0 new messages