Output Image from Web Server to Web Browser
[1/3] from: vonja:sbcglobal at: 11-Oct-2008 22:12
Hello Rebol Group:
I'm attempting to output a binary image
from a server (i.e., Linux) cgi script
to a web browser using the below codes
but I've been unsuccessful. I've scoured
Rebol sources on and offline to no avail.
Thanks in advance for your help. --Von
For example:
Rebol []
data: read/binary %/some/image.jpg
print "Content-Type: image/jpg^/"
;; or "Content-Type: image/jpeg^/^/"
;; or "Content-Type: image/jpeg"
write-io system/ports/output data length? Data
;; or print data
;; or print join "Location: " data
;; with or w/o print join "Expires: 0" newline
[2/3] from: compkarori:gm:ail at: 12-Oct-2008 8:52
Von
This is what I do in Cheyenne - code taken from my web to hylafax portal
recvqdir: %/var/spool/hylafax/recvq/
file: dehex request/content/filename
switch suffix? file [
%.tif [ response/set-header 'Content-type "image/tiff" ]
%.pdf [ response/set-header 'Content-type "application/pdf" ]
]
response/set-header 'Content-disposition join "attachment; filename=" file
response/buffer: read/binary join recvqdir file file
On Sun, Oct 12, 2008 at 6:12 PM, Von <vonja-sbcglobal.net> wrote:
> Hello Rebol Group:
> I'm attempting to output a binary image
<<quoted lines omitted: 16>>
> To unsubscribe from the list, just send an email to
> lists at rebol.com with unsubscribe as the subject.
--
Graham Chiu
http://www.synapsedirect.com
Synapse - the use from anywhere EMR.
[3/3] from: vonja::sbcglobal::net at: 13-Oct-2008 11:03
Hello Graham,
I appreciate your response. Unfortunately,
I attempted to apply your code with some modifications
but I was unsuccessful. I WAS able to resolve
the issue so if anyone is interested for a future
project there will be a simple solution. I did take
advantage of your switch suffix? Statement :-)
It should read as:
Rebol []
data: read/binary %/some/image.jpg
print ["Content-Type: image/jpg" newline] ;; or replace newline with "^M^J"
write-io system/ports/output data length? data
;; the below lines will not work
;; or print "Content-Type: image/jpeg^/^/"
;; or print "Content-Type: image/jpeg"
;; or print "Content-Type: image/jpeg^/"
;; or print ["Content-Type: image/jpeg" "^/^/"]
Notes
- Quoted lines have been omitted from some messages.
View the message alone to see the lines that have been omitted