unofficial mirror of guile-user@gnu.org 
 help / color / mirror / Atom feed
* Uploading Word documents, PDFs, PNG files etc
@ 2009-05-10 16:21 Sebastian Tennant
  2009-05-11 15:11 ` Ludovic Courtès
  2009-05-12  3:15 ` Thien-Thi Nguyen
  0 siblings, 2 replies; 22+ messages in thread
From: Sebastian Tennant @ 2009-05-10 16:21 UTC (permalink / raw)
  To: guile-user

Hi Guilers,

The following works fine for plain text files but fails with Word
documents, PDFs, PNG files and no doubt other (binary?) file types.

This error msg, followed by the contents of the file, is dumped on
stderr each time:

 string contains #\nul character: "\x0d
 Content-Disposition: form-data; name=\"File-Upload\"; filename=\"eap_logo.png\"\x0d
 Content-Type: image/png\x0d
 \x0d
 .
 .


---8<---8<---8<---8<---8<---8<---8<---8<---8<---8<---8<

 (use-modules (www cgi))

 [...]

 (let* ((upload (cgi:upload "File-Upload"))
        (props-alist (object-property upload #:guile-www-cgi))
        ;;(object-property ...) is deprecated
        (upload-fname (transform-string
                       (assoc-ref props-alist #:filename)
                       #\  #\_)))
   (with-output-to-file (string-append USER-UPLOAD-DIR upload-fname)
     (lambda ()
       (display upload)))))

---8<---8<---8<---8<---8<---8<---8<---8<---8<---8<---8<

How should I go about getting uploaded binary files out of memory and
onto disk?

Any help/advice/pointers much appreciated.

Seb

P.S. 'Writing' rather than 'displaying' the uploaded file makes no
     difference (and is not what I want).

-- 
Emacs' AlsaPlayer - Music Without Jolts
Lightweight, full-featured and mindful of your idyllic happiness.
http://home.gna.org/eap





^ permalink raw reply	[flat|nested] 22+ messages in thread

end of thread, other threads:[~2009-05-21 10:47 UTC | newest]

Thread overview: 22+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-05-10 16:21 Uploading Word documents, PDFs, PNG files etc Sebastian Tennant
2009-05-11 15:11 ` Ludovic Courtès
2009-05-11 15:55   ` Thien-Thi Nguyen
2009-05-11 23:17     ` Ludovic Courtès
2009-05-12  3:15 ` Thien-Thi Nguyen
2009-05-12 10:15   ` Sebastian Tennant
2009-05-12 10:33     ` Ludovic Courtès
2009-05-12 11:16       ` Sebastian Tennant
2009-05-13 14:02   ` Sebastian Tennant
2009-05-13 15:02     ` Ludovic Courtès
2009-05-13 18:01       ` Sebastian Tennant
2009-05-13 19:09       ` Sebastian Tennant
2009-05-13 19:23         ` Linas Vepstas
2009-05-14  3:47           ` Keith Wright
2009-05-14 12:49             ` Sebastian Tennant
2009-05-14 13:13               ` Sebastian Tennant
2009-05-17 21:55               ` Ludovic Courtès
2009-05-19  4:48                 ` Sebastian Tennant
2009-05-19  4:59                   ` Sebastian Tennant
2009-05-19  7:50                   ` Ludovic Courtès
2009-05-21  5:22                     ` Sebastian Tennant
2009-05-21 10:47                       ` Thien-Thi Nguyen

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).