Serving static files that are not in the webroot from awful pasted by andyjpb on Mon Apr 9 20:41:24 2012
(define-sxml-page (regexp "/assets/.+/THUMBNAIL")
(lambda (path)
(let* ((paths (string-split path "/"))
(asset_id (second paths))
)
(let ((filename (SELECT filename from table where asset_id = @asset_id AND type=thumbnail)))
(contents-of filename))
)))
no title pasted by andyjpb on Mon Apr 9 20:45:36 2012
(define-sxml-page (regexp "/assets/.+/THUMBNAIL")
(lambda (path)
(let* ((paths (string-split path "/"))
(asset_id (second paths))
)
(let-values (((filename mime_type) (SELECT filename, mime_type from table where asset_id = @asset_id AND type=thumbnail)))
(awful-response-headers '((content-type ,mime_type))))
(flush-headers)
(sendfile (current-response-port) (contents-of filename))
)
)))403 - Forbidden pasted by andyjpb on Mon Apr 9 21:05:09 2012
(define-page (regexp "/assets/.+/.+")
(lambda (path)
(let* ((paths (string-split path "/"))
(asset-id (second paths))
(type (third paths)))
(awful-response-headers `((content-type image/jpeg)))
(send-static-file "/home/local/andyjpb/.../thumbs/IMG_5021.JPG")
""
))
no-template: #t)
Working! added by andyjpb on Mon Apr 9 21:12:45 2012
(define-page (regexp "/assets/.+/.+")
(lambda (path)
(let* ((paths (string-split path "/"))
(asset-id (second paths))
(type (third paths)))
(awful-response-headers `((content-type image/jpeg)))
(parameterize ((root-path (pathname-directory "/home/local/andyjpb/.../thumbs/IMG_5021.JPG")))
(send-static-file (pathname-strip-directory "/home/local/andyjpb/.../thumbs/IMG_5021.JPG")))
""
))