[drakma-devel] File uploading: adding streams and functions to the list of parameters

Andrei Stebakov lispercat at gmail.com
Fri Jun 8 15:19:43 UTC 2007


Recently I've been thinking how to make http-request upload a file, but not
from the hard drive but from a function which can produce (or write to a)
stream.
Let's say I want to create an image with cl-gd but instead of writing the
image to the file and then creating the http-request with a pathname of the
file I can pass a
(lambda (stream)
   (cl-gd-create-image stream your param1 param2))
in place of the pathname parameter. Or a stream which already has the file
data.
I was trying to do it using :content :continuation but found it too
difficult, maybe I missed other ways.
Anyway, I created a patch with very minimal changes to the
make-form-data-function function which allows to do so. Also I found that I
set *header-stream* to not nil, I was missing the debug output produced by
the character (character only) stream from make-form-data-function which
basically shows all the parameters we are sending. I added the primitive
support for this based on make-broadcast-stream.
Here I attach the patch for your kind consideration.

Thank you,
Andrew
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mailman.common-lisp.net/pipermail/drakma-devel/attachments/20070608/f7a2759b/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: file-as-function.patch
Type: application/octet-stream
Size: 3705 bytes
Desc: not available
URL: <https://mailman.common-lisp.net/pipermail/drakma-devel/attachments/20070608/f7a2759b/attachment.obj>


More information about the Drakma-devel mailing list