[tbnl-devel] Add hook before uploading a file.

Edi Weitz edi at agharta.de
Sun Sep 17 22:08:03 UTC 2006


On Sun, 17 Sep 2006 14:45:02 -0400, "Erik Enge" <erik.enge at gmail.com> wrote:

> My users will upload files as large as 500M to my servers.  This
> will of course take awhile and I think it's asking for trouble to
> let them submit and then just let the browser sit there and spin a
> currently-working-cursor without any other feedback.  So, I use an
> IFRAME and some Ajax to submit the form and also poll to see how the
> submittion is coming along.  Then I report this to user in the form
> of a progress-bar.
>
> (Lots of examples of this, just search for "ajax upload progress" in
> Google.)

See also here:

  http://common-lisp.net/pipermail/tbnl-devel/2006-February/000559.html

> Anyway, by default in TBNL, as far as I can tell, the request
> doesn't hit my code until after the file has been uploaded.  What I
> think I really need instead is to have access to the temporary
> filename created for the upload (so I can track its size) right
> before TBNL starts reading the file.
>
> I've put this together locally by creating a hook in
> MAKE-TMP-FILE-NAME[1] which is simply called with the tmp-file-name
> created before returning.  In my code I then use this filename to
> create data for the progress-bar.
>
> My question is whether there's a better way to achieve this and/or
> whether or not you want a patch.

I don't think there's a better way.  But do you think that a hook for
MAKE-TMP-FILE-NAME is the right solution?  At that point you won't
know for /which/ uploaded file you're called.

> [1] I think a comment explaining that it's called from the RFC2388
> code would've been really helpful.  :-)

Hehe, yeah, even "Edit Callers" won't help you much in this case... :)

Seriously, this is a bit hacky anyway because the RFC2388 calls back
into TBNL.  I'd like to have a cleaner solution, but that'd probably
imply that TBNL implements its own RFC2388 parsing.

I'd like to provide something in TBNL to enable things like upload
progress bars, but I'm still looking for a solution that looks clean
and unobtrusive to me.

Cheers,
Edi.



More information about the Tbnl-devel mailing list