From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Sebastian Tennant Newsgroups: gmane.lisp.guile.user Subject: Uploading Word documents, PDFs, PNG files etc Date: Sun, 10 May 2009 16:21:29 +0000 Message-ID: NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: ger.gmane.org 1241972517 31581 80.91.229.12 (10 May 2009 16:21:57 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Sun, 10 May 2009 16:21:57 +0000 (UTC) To: guile-user@gnu.org Original-X-From: guile-user-bounces+guile-user=m.gmane.org@gnu.org Sun May 10 18:21:48 2009 Return-path: Envelope-to: guile-user@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.50) id 1M3Bmc-0007Jv-U4 for guile-user@m.gmane.org; Sun, 10 May 2009 18:21:47 +0200 Original-Received: from localhost ([127.0.0.1]:46808 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1M3Bmc-0005ck-73 for guile-user@m.gmane.org; Sun, 10 May 2009 12:21:46 -0400 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1M3BmX-0005ay-BC for guile-user@gnu.org; Sun, 10 May 2009 12:21:41 -0400 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1M3BmS-0005ZB-R8 for guile-user@gnu.org; Sun, 10 May 2009 12:21:40 -0400 Original-Received: from [199.232.76.173] (port=48052 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1M3BmS-0005Z8-MW for guile-user@gnu.org; Sun, 10 May 2009 12:21:36 -0400 Original-Received: from main.gmane.org ([80.91.229.2]:39185 helo=ciao.gmane.org) by monty-python.gnu.org with esmtps (TLS-1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1M3BmS-0008SD-95 for guile-user@gnu.org; Sun, 10 May 2009 12:21:36 -0400 Original-Received: from list by ciao.gmane.org with local (Exim 4.43) id 1M3BmN-0006L2-Kj for guile-user@gnu.org; Sun, 10 May 2009 16:21:31 +0000 Original-Received: from vps203.linuxvps.org ([91.186.7.203]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Sun, 10 May 2009 16:21:31 +0000 Original-Received: from sebyte by vps203.linuxvps.org with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Sun, 10 May 2009 16:21:31 +0000 X-Injected-Via-Gmane: http://gmane.org/ Original-Lines: 48 Original-X-Complaints-To: usenet@ger.gmane.org X-Gmane-NNTP-Posting-Host: vps203.linuxvps.org X-Composed-In: Gnus User-Agent: Gnus/5.110011 (No Gnus v0.11) Emacs/22.2 (gnu/linux) Cancel-Lock: sha1:fyd9WRtoOUPb/Opzwr4tPXV+AUo= X-detected-operating-system: by monty-python.gnu.org: GNU/Linux 2.6, seldom 2.4 (older, 4) X-BeenThere: guile-user@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: General Guile related discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: guile-user-bounces+guile-user=m.gmane.org@gnu.org Errors-To: guile-user-bounces+guile-user=m.gmane.org@gnu.org Xref: news.gmane.org gmane.lisp.guile.user:7280 Archived-At: 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