1 Reply Latest reply on Apr 2, 2007 1:56 PM by c_wigginton

    Can CF send file to Box on Network and Spawn Client?

    Mark Forsberg Level 1
      Sorry about the first message with no title. I'm over multi-tasking.

      I want to use CF to track the use of reports on our network. I would like to have the user click on a link, have CF log the user info behind the scenes and then pass that link to the requesting machine. The reports are on our network and are run by the Business Objects 5.0 client on the local machines.
      I've tried variations of cfcontent, but have had no luck. Can Coldfusion pass the report to the requesting machine and then the local machine spawns the BO client?
      Thanks.

      Mark F.
        • 1. Re: Can CF send file to Box on Network and Spawn Client?
          c_wigginton Level 1
          Assuming your business object client accesses the report via a url on the web, it has a mime type associated with it. I know you stated you've used several methods of cfcontent, but it is worth another try.

          With the example below, you could generate a list of the reports available, where the link is handled by a wrapper to the report. The mime udf was obtained from cflib.org. If you don't see the mime type of your report in the list, you would need to add it.

          Note: code abbreviated, use your own flavor of sql validation and security.

          --- getReport.cfm ---
          <cfsetting enablecfoutputonly="yes">

          <cfquery name="qryReportPath" datasource="reportDSN">
          select reportFilePath from reports where report_id = #url.report_id#
          </cfquery>

          <!--- add any metrics here you wish --->

          <cfinclude template="fileWrapper.cfm">

          ---- fileWrapper.cfm ----
          <cfscript>
          /**
          * Returns mime type and subtype for a file.
          *
          * @param filename File name to examine. (Required)
          * @return Returns a string.
          * @author Kenneth Rainey (kip.rainey@incapital.com)
          * @version 1, April 21, 2004
          */
          function getMimeType(filename) {
          var mimeStruct=structNew();
          var fileExtension ="";
          //extract file extension from file name
          fileExtension = Reverse(SpanExcluding(Reverse(fileName),"."));
          //build mime type array
          mimeStruct.ai="application/postscript";
          mimeStruct.aif="audio/x-aiff";
          mimeStruct.aifc="audio/x-aiff";
          mimeStruct.aiff="audio/x-aiff";
          mimeStruct.asc="text/plain";
          mimeStruct.au="audio/basic";
          mimeStruct.avi="video/x-msvideo";
          mimeStruct.bcpio="application/x-bcpio";
          mimeStruct.bin="application/octet-stream";
          mimeStruct.c="text/plain";
          mimeStruct.cc="text/plain";
          mimeStruct.ccad="application/clariscad";
          mimeStruct.cdf="application/x-netcdf";
          mimeStruct.class="application/octet-stream";
          mimeStruct.cpio="application/x-cpio";
          mimeStruct.cpt="application/mac-compactpro";
          mimeStruct.csh="application/x-csh";
          mimeStruct.css="text/css";
          mimeStruct.dcr="application/x-director";
          mimeStruct.dir="application/x-director";
          mimeStruct.dms="application/octet-stream";
          mimeStruct.doc="application/msword";
          mimeStruct.drw="application/drafting";
          mimeStruct.dvi="application/x-dvi";
          mimeStruct.dwg="application/acad";
          mimeStruct.dxf="application/dxf";
          mimeStruct.dxr="application/x-director";
          mimeStruct.eps="application/postscript";
          mimeStruct.etx="text/x-setext";
          mimeStruct.exe="application/octet-stream";
          mimeStruct.ez="application/andrew-inset";
          mimeStruct.f="text/plain";
          mimeStruct.f90="text/plain";
          mimeStruct.fli="video/x-fli";
          mimeStruct.gif="image/gif";
          mimeStruct.gtar="application/x-gtar";
          mimeStruct.gz="application/x-gzip";
          mimeStruct.h="text/plain";
          mimeStruct.hdf="application/x-hdf";
          mimeStruct.hh="text/plain";
          mimeStruct.hqx="application/mac-binhex40";
          mimeStruct.htm="text/html";
          mimeStruct.html="text/html";
          mimeStruct.ice="x-conference/x-cooltalk";
          mimeStruct.ief="image/ief";
          mimeStruct.iges="model/iges";
          mimeStruct.igs="model/iges";
          mimeStruct.ips="application/x-ipscript";
          mimeStruct.ipx="application/x-ipix";
          mimeStruct.jpe="image/jpeg";
          mimeStruct.jpeg="image/jpeg";
          mimeStruct.jpg="image/jpeg";
          mimeStruct.js="application/x-javascript";
          mimeStruct.kar="audio/midi";
          mimeStruct.latex="application/x-latex";
          mimeStruct.lha="application/octet-stream";
          mimeStruct.lsp="application/x-lisp";
          mimeStruct.lzh="application/octet-stream";
          mimeStruct.m="text/plain";
          mimeStruct.man="application/x-troff-man";
          mimeStruct.me="application/x-troff-me";
          mimeStruct.mesh="model/mesh";
          mimeStruct.mid="audio/midi";
          mimeStruct.midi="audio/midi";
          mimeStruct.mif="application/vnd.mif";
          mimeStruct.mime="www/mime";
          mimeStruct.mov="video/quicktime";
          mimeStruct.movie="video/x-sgi-movie";
          mimeStruct.mp2="audio/mpeg";
          mimeStruct.mp3="audio/mpeg";
          mimeStruct.mpe="video/mpeg";
          mimeStruct.mpeg="video/mpeg";
          mimeStruct.mpg="video/mpeg";
          mimeStruct.mpga="audio/mpeg";
          mimeStruct.ms="application/x-troff-ms";
          mimeStruct.msh="model/mesh";
          mimeStruct.nc="application/x-netcdf";
          mimeStruct.oda="application/oda";
          mimeStruct.pbm="image/x-portable-bitmap";
          mimeStruct.pdb="chemical/x-pdb";
          mimeStruct.pdf="application/pdf";
          mimeStruct.pgm="image/x-portable-graymap";
          mimeStruct.pgn="application/x-chess-pgn";
          mimeStruct.png="image/png";
          mimeStruct.pnm="image/x-portable-anymap";
          mimeStruct.pot="application/mspowerpoint";
          mimeStruct.ppm="image/x-portable-pixmap";
          mimeStruct.pps="application/mspowerpoint";
          mimeStruct.ppt="application/mspowerpoint";
          mimeStruct.ppz="application/mspowerpoint";
          mimeStruct.pre="application/x-freelance";
          mimeStruct.prt="application/pro_eng";
          mimeStruct.ps="application/postscript";
          mimeStruct.qt="video/quicktime";
          mimeStruct.ra="audio/x-realaudio";
          mimeStruct.ram="audio/x-pn-realaudio";
          mimeStruct.ras="image/cmu-raster";
          mimeStruct.rgb="image/x-rgb";
          mimeStruct.rm="audio/x-pn-realaudio";
          mimeStruct.roff="application/x-troff";
          mimeStruct.rpm="audio/x-pn-realaudio-plugin";
          mimeStruct.rtf="text/rtf";
          mimeStruct.rtx="text/richtext";
          mimeStruct.scm="application/x-lotusscreencam";
          mimeStruct.set="application/set";
          mimeStruct.sgm="text/sgml";
          mimeStruct.sgml="text/sgml";
          mimeStruct.sh="application/x-sh";
          mimeStruct.shar="application/x-shar";
          mimeStruct.silo="model/mesh";
          mimeStruct.sit="application/x-stuffit";
          mimeStruct.skd="application/x-koan";
          mimeStruct.skm="application/x-koan";
          mimeStruct.skp="application/x-koan";
          mimeStruct.skt="application/x-koan";
          mimeStruct.smi="application/smil";
          mimeStruct.smil="application/smil";
          mimeStruct.snd="audio/basic";
          mimeStruct.sol="application/solids";
          mimeStruct.spl="application/x-futuresplash";
          mimeStruct.src="application/x-wais-source";
          mimeStruct.step="application/STEP";
          mimeStruct.stl="application/SLA";
          mimeStruct.stp="application/STEP";
          mimeStruct.sv4cpio="application/x-sv4cpio";
          mimeStruct.sv4crc="application/x-sv4crc";
          mimeStruct.swf="application/x-shockwave-flash";
          mimeStruct.t="application/x-troff";
          mimeStruct.tar="application/x-tar";
          mimeStruct.tcl="application/x-tcl";
          mimeStruct.tex="application/x-tex";
          mimeStruct.texi="application/x-texinfo";
          mimeStruct.texinfo="application/x-texinfo";
          mimeStruct.tif="image/tiff";
          mimeStruct.tiff="image/tiff";
          mimeStruct.tr="application/x-troff";
          mimeStruct.tsi="audio/TSP-audio";
          mimeStruct.tsp="application/dsptype";
          mimeStruct.tsv="text/tab-separated-values";
          mimeStruct.txt="text/plain";
          mimeStruct.unv="application/i-deas";
          mimeStruct.ustar="application/x-ustar";
          mimeStruct.vcd="application/x-cdlink";
          mimeStruct.vda="application/vda";
          mimeStruct.viv="video/vnd.vivo";
          mimeStruct.vivo="video/vnd.vivo";
          mimeStruct.vrml="model/vrml";
          mimeStruct.wav="audio/x-wav";
          mimeStruct.wrl="model/vrml";
          mimeStruct.xbm="image/x-xbitmap";
          mimeStruct.xlc="application/vnd.ms-excel";
          mimeStruct.xll="application/vnd.ms-excel";
          mimeStruct.xlm="application/vnd.ms-excel";
          mimeStruct.xls="application/vnd.ms-excel";
          mimeStruct.xlw="application/vnd.ms-excel";
          mimeStruct.xml="text/xml";
          mimeStruct.xpm="image/x-xpixmap";
          mimeStruct.xwd="image/x-xwindowdump";
          mimeStruct.xyz="chemical/x-pdb";
          mimeStruct.zip="application/zip";
          if(structKeyExists(mimeStruct,fileExtension)) return mimeStruct[fileExtension];
          else return "unknown/unknown";
          }
          </cfscript>



          <cffile action="read" file="#qryReportPath.reportFilePath#" variable="tempFile">
          <cfcontent type="#getMimeType(GetFileFromPath(qryReportPath.reportFilePath))#" reset="yes">
          <CFHEADER NAME="content-disposition" VALUE="attachment; filename=#GetFileFromPath(qryReportPath.reportFilePath)#">
          <cfoutput>#tempFile#</cfoutput>
          <cfsetting enablecfoutputonly="no">