Page 1 of 1

Send the new file over HTTP (server part)

Posted: Tue Jul 28, 2015 5:56 am
by anaumov
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

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

Posted: Tue Jul 28, 2015 5:33 pm
by pjstirling
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/

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

Posted: Wed Jul 29, 2015 1:54 am
by anaumov
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?

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

Posted: Thu Jul 30, 2015 2:12 am
by anaumov
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...