# Copyright for the Uniform Repository Service (c) 1995 - 2007, # by Gerald Banon. All rights reserved. # Version 2.1 # simpledownload.tcl proc Download {} { if [catch { global env fconfigure stdout -translation binary # puts {Content-Type: text/html} set col ../../../../.. set URLibServiceRepository $env(URLIB_SERVICE_REP) source ../$col/$URLibServiceRepository/doc/utilities1.tcl source ../$col/$URLibServiceRepository/doc/cgi/mirrorfind-.tcl # homePath set homePath $env(DOCUMENT_ROOT) set pathInfo [file split $env(PATH_INFO)] # currentRep regsub -all { } [lrange $pathInfo 1 4] {/} currentRep set localURLibClientSocketId [StartCommunication $env(SERVER_NAME) $env(URLIB_PORT)] set metadataRep [Submit $localURLibClientSocketId [list FindMetadataRep $currentRep]] set targetFile [Submit $localURLibClientSocketId [list GetFieldValue $metadataRep-0 targetfile] 0] ;# not async close $localURLibClientSocketId Load $homePath/col/$currentRep/doc/$targetFile fileContent binary puts "Content-disposition: attachment; filename=$targetFile" puts {} puts $fileContent } m] { puts {Content-Type: text/html} puts {} puts $m if 0 {global errorInfo; puts $errorInfo} } }