Send the new file over HTTP (server part)

Discussion of Common Lisp
Post Reply
anaumov
Posts: 10
Joined: Thu Sep 15, 2011 4:13 am
Location: Germany
Contact:

Send the new file over HTTP (server part)

Post by anaumov » Tue Jul 28, 2015 5:56 am

Hello everyone,

does anybody know how to send the new created file over the web?
I have one script that creates new file. It works fine, but now I need to run this script on the web-server and download generated file via browser.

Thanks for your help and time,
Alex

pjstirling
Posts: 166
Joined: Sun Nov 28, 2010 4:21 pm

Re: Send the new file over HTTP (server part)

Post by pjstirling » Tue Jul 28, 2015 5:33 pm

Your English leaves something to be desired, but:

A library for making http requests (which would let you upload files) is http://weitz.de/drakma/

A library for making web-servers (that will handle requests for files from web-browsers) is http://weitz.de/hunchentoot/

Both are available through http://quicklisp.org/

anaumov
Posts: 10
Joined: Thu Sep 15, 2011 4:13 am
Location: Germany
Contact:

Re: Send the new file over HTTP (server part)

Post by anaumov » Wed Jul 29, 2015 1:54 am

I don't need to make http requests or web-servers...

I just want to save a file (on client side, via browser) that will be created on the server side (standard output).
The question is how to send the output-stream (in my case it's a file) to standard-output?

anaumov
Posts: 10
Joined: Thu Sep 15, 2011 4:13 am
Location: Germany
Contact:

Re: Send the new file over HTTP (server part)

Post by anaumov » Thu Jul 30, 2015 2:12 am

The answer is

Code: Select all

(format t "Content-Type:application/vnd.ms-excel~%")
(format t "Content-Disposition:attachment;filename=file.xls~%~%")
(princ "Test. Ok!")
But now I have another question: what's wrong with this code?

Code: Select all

#!/usr/bin/sbcl --script
(let ((quicklisp-init (merge-pathnames "quicklisp/setup.lisp" (user-homedir-pathname))))
  (when (probe-file quicklisp-init)
    (load quicklisp-init)))

(ql:quickload "buildnode-excel")

(format t "Content-Type:application/vnd.ms-excel~%")
(format t "Content-Disposition:attachment;filename=file.xls~%~%")
(princ "Test. Ok!")
After removing (ql:quickload "buildnode-excel") it works...

Post Reply