• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

pdfs, cfcs and webservices

LEGEND ,
Jul 07, 2006 Jul 07, 2006

Copy link to clipboard

Copied

Hopefully someone can help me with this so I figure out what I'm doing
wrong.

I have a cfc that is using cffile to grab pdfs, avis, mpegs, etc. and
returning it to the user. For some reason can't get it through to the user.
On the "invoking page" I'm using cfheader and cfcontent to try and send the
file as an attachment to the user, but it won't work. If I cfdump the
variable I get data, but I'm never prompted to open/save the file. Using
regular cfm pages I have no problems. I have tried read, readbinary,
toBinary with no luck.

Also I need this function to accessible as a webservice and trying that
keeps returning an error about an invalid wsdl file and couldn't create
stubs, but calling it from the same site results in the issue above but no
wsdl error.

CFC Code
-----------
<cffunction name="getFile" access="remote" displayname="Get File" hint="I
get a file based on the passed id.">
<cfargument name="docID" type="string" required="yes">
<cfset var doc = '' />
<cfset var filePath = expandPath('../Web_Support_Doc/') & arguments.docID
/>
<cffile action="readbinary" file="#filePath#" variable="doc" />
<cfreturn doc>
</cffunction>

Invocation Code
------------------
<cfsilent>
<cfset docFile =
createObject('component','_cfcs.file').getFile('1255KITG.pdf') />
</cfsilent>

<cfheader name="Content-Disposition" value="attachment;
filename=1255KITG.pdf">
<cfcontent type="application/unknown" file="#docFile#">

Web Service invocation code
---------------------------------
<cfset docFile =
createObject('webservice',' http://innet/_cfcs/file.cfc?method=getFile&docID=#url.docID#')
/>

I'm using the same cfheader/cfcontent code from above to send to user.

Any help would be greatly appreciated.

--
Bryan Ashcraft (remove brain to reply)
Web Application Developer
Wright Medical Technologies, Inc.
------------------------------------------------------------------
Macromedia Certified Dreamweaver Developer
Adobe Community Expert (DW) :: http://www.adobe.com/communities/experts/



TOPICS
Advanced techniques

Views

1.6K

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Jul 10, 2006 Jul 10, 2006

Copy link to clipboard

Copied

No ideas? :(

--
Bryan Ashcraft (remove brain to reply)
Web Application Developer
Wright Medical Technologies, Inc.
------------------------------------------------------------------
Macromedia Certified Dreamweaver Developer
Adobe Community Expert (DW) :: http://www.adobe.com/communities/experts/


"Bash **AdobeCommunityExpert**" <bashcraft@wmtBRAIN.com> wrote in message
news:e8n26h$fck$1@forums.macromedia.com...
> Hopefully someone can help me with this so I figure out what I'm doing
> wrong.
>
> I have a cfc that is using cffile to grab pdfs, avis, mpegs, etc. and
> returning it to the user. For some reason can't get it through to the
> user. On the "invoking page" I'm using cfheader and cfcontent to try and
> send the file as an attachment to the user, but it won't work. If I cfdump
> the variable I get data, but I'm never prompted to open/save the file.
> Using regular cfm pages I have no problems. I have tried read, readbinary,
> toBinary with no luck.
>
> Also I need this function to accessible as a webservice and trying that
> keeps returning an error about an invalid wsdl file and couldn't create
> stubs, but calling it from the same site results in the issue above but no
> wsdl error.
>
> CFC Code
> -----------
> <cffunction name="getFile" access="remote" displayname="Get File" hint="I
> get a file based on the passed id.">
> <cfargument name="docID" type="string" required="yes">
> <cfset var doc = '' />
> <cfset var filePath = expandPath('../Web_Support_Doc/') & arguments.docID
> />
> <cffile action="readbinary" file="#filePath#" variable="doc" />
> <cfreturn doc>
> </cffunction>
>
> Invocation Code
> ------------------
> <cfsilent>
> <cfset docFile =
> createObject('component','_cfcs.file').getFile('1255KITG.pdf') />
> </cfsilent>
>
> <cfheader name="Content-Disposition" value="attachment;
> filename=1255KITG.pdf">
> <cfcontent type="application/unknown" file="#docFile#">
>
> Web Service invocation code
> ---------------------------------
> <cfset docFile =
> createObject('webservice',' http://innet/_cfcs/file.cfc?method=getFile&docID=#url.docID#')
> />
>
> I'm using the same cfheader/cfcontent code from above to send to user.
>
> Any help would be greatly appreciated.
>
> --
> Bryan Ashcraft (remove brain to reply)
> Web Application Developer
> Wright Medical Technologies, Inc.
> ------------------------------------------------------------------
> Macromedia Certified Dreamweaver Developer
> Adobe Community Expert (DW) :: http://www.adobe.com/communities/experts/
>
>
>


Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Jul 10, 2006 Jul 10, 2006

Copy link to clipboard

Copied

What about putting the code to send the documents to the client in the
cfc function. This is the only way I can even imagine this working as a
webservice. Because, otherwise, what is the returntype for "document?"



Bash **AdobeCommunityExpert** wrote:
> No ideas? :(
>

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Jul 11, 2006 Jul 11, 2006

Copy link to clipboard

Copied

I'm obviously brain dead due to this deadline as I didn't even think of
that. Thanks! I'll give it a shot.

--
Bryan Ashcraft (remove brain to reply)
Web Application Developer
Wright Medical Technologies, Inc.
------------------------------------------------------------------
Macromedia Certified Dreamweaver Developer
Adobe Community Expert (DW) :: http://www.adobe.com/communities/experts/


"Ian Skinner" <ian.skinner@bloodsource.org> wrote in message
news:e8uk8h$ek2$1@forums.macromedia.com...
> What about putting the code to send the documents to the client in the cfc
> function. This is the only way I can even imagine this working as a
> webservice. Because, otherwise, what is the returntype for "document?"
>
>
>
> Bash **AdobeCommunityExpert** wrote:
>> No ideas? :(
>>


Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Jul 11, 2006 Jul 11, 2006

Copy link to clipboard

Copied

Well that didn't work either. :(

--
Bryan Ashcraft (remove brain to reply)
Web Application Developer
Wright Medical Technologies, Inc.
------------------------------------------------------------------
Macromedia Certified Dreamweaver Developer
Adobe Community Expert (DW) :: http://www.adobe.com/communities/experts/


"Ian Skinner" <ian.skinner@bloodsource.org> wrote in message
news:e8uk8h$ek2$1@forums.macromedia.com...
> What about putting the code to send the documents to the client in the cfc
> function. This is the only way I can even imagine this working as a
> webservice. Because, otherwise, what is the returntype for "document?"
>
>
>
> Bash **AdobeCommunityExpert** wrote:
>> No ideas? :(
>>


Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Jul 11, 2006 Jul 11, 2006

Copy link to clipboard

Copied

Can you provide some working, NON-CFC code. Serving up documents like
this is something I've only done once in the last ten years, and I do
not remember all the details.

Bash **AdobeCommunityExpert** wrote:
> Well that didn't work either. :(
>

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Jul 11, 2006 Jul 11, 2006

Copy link to clipboard

Copied

If I use this code:

<!--- Send HTTP request for file from intranet and serve file to user--->
<cfhttp method="get" url=" http://domain/load_doc.cfm?doc=#url.doc#"
timeout="60" throwonerror="yes"></cfhttp>
</cfsilent>
<!--- Set default headers for serving file and serve file up to user--->
<cfheader name="Content-Type" value="pdf">
<cfheader name="Content-Disposition" value="attachment; filename=#url.doc#">
<cfcontent type="application/pdf">

<cfoutput>#cfhttp.filecontent#</cfoutput>

To call this code:

<!--- Define the full path to the docs --->
<cfset doc_path = expandPath("../../Web_Support_Doc/") & 'ACCSLIT.pdf' />

<!--- Verify the requested file exists --->
<cfif fileExists(doc_path)>

<!--- If file exists, serve it up --->
<cfcontent type="application/pdf" file="#doc_path#" />
<cfabort />

<!--- Otherwise display error --->
<cfelse>
<cfset error = "We're sorry, the file you have requested is not available."
/>
<cfinclude template="error.cfm" />
<cfabort />
</cfif>


It works fine. But if I use this code:

<cfset docFile =
createObject('webservice',' http://innet/_cfcs/docLoader.cfc?method=read&docID=#url.docID#')
/>
<cfheader name="Content-Type" value="pdf">
<cfheader name="Content-Disposition" value="attachment;
filename=#url.docID#">
<cfcontent type="application/pdf">
<cfoutput>#docFile#</cfoutput>
<cfabort />

To call this code:

<cfcomponent>
<cffunction name="read" access="remote" displayname="Read File" hint="I
read a file based on the passed id." output="false" returntype="binary">
<cfargument name="docID" type="string" required="yes">
<cfset var doc = '' />
<cfset var filePath = expandPath('../Web_Support_Doc/') & arguments.docID
/>
<cfif fileExists(filePath)>
<cffile variable="doc" action="readbinary" file="#filePath#" />
</cfif>
<cfreturn doc />
</cffunction>
</cfcomponent>

It doesn't.

--
Bryan Ashcraft (remove brain to reply)
Web Application Developer
Wright Medical Technologies, Inc.
------------------------------------------------------------------
Macromedia Certified Dreamweaver Developer
Adobe Community Expert (DW) :: http://www.adobe.com/communities/experts/


"Ian Skinner" <ian.skinner@bloodsource.org> wrote in message
news:e90s98$c07$1@forums.macromedia.com...
> Can you provide some working, NON-CFC code. Serving up documents like
> this is something I've only done once in the last ten years, and I do not
> remember all the details.
>
> Bash **AdobeCommunityExpert** wrote:
>> Well that didn't work either. :(
>>


Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Jul 11, 2006 Jul 11, 2006

Copy link to clipboard

Copied

I have been playing with this just a bit. I can make this work.

fileServing.cfm
---------------
<cfset testObj = createObject("component", "fileServing")>

<cfset testObj.serveFile("test.pdf")>

fileServing.cfc
---------------
<cfcomponent>
<cffunction name="serveFile" access="remote" returntype="void">
<cfargument name="fileToServe" required="yes" type="string">

<cfheader name="Content-Disposition" value="attachment;
filename=#arguments.fileToServe#">
<cfcontent file="G:\Playground\ProBono\#arguments.fileToServe#"
reset="no" type="application/unknown">

</cffunction>
</cfcomponent>

But when I try to use it as a web service, I get errors. I suspect that
a web service works differently and may not be easily usable in this
manner.

A clearer idea of what you goal is could be useful.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Jul 11, 2006 Jul 11, 2006

Copy link to clipboard

Copied

I have played with it some more and maybe getting closer. This gets a
file to download, but it is apparently corrupted and Adobe
Reader/Acrobat can not open it.


fileServing.cfm
---------------
<cfset myFile="test.pdf">

<cfheader name="Content-Disposition" value="attachment; filename=#Myfile#">

<cfset testObj = createObject("webservice",
" http://playground/probono/fileServing.cfc?wsdl")>

<cfcontent type="application/unknown">
<cfoutput>#binaryDecode(testObj.serveFile(myFile),"Hex")#</cfoutput>

fileServing.cfc
---------------
<cfcomponent>
<cffunction name="serveFile" access="remote" returntype="string">
<cfargument name="fileToServe" required="yes" type="string">

<cfset var fileObj = "">
<cfset var returnVar = "">

<cffile action="readbinary"
file="g:\playground\probono\#arguments.fileToServe#" variable="fileObj">
<cfset returnVar = binaryEncode(fileObj,"Hex")>

<cfreturn returnVar>
</cffunction>
</cfcomponent>

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Jul 11, 2006 Jul 11, 2006

Copy link to clipboard

Copied

Can you provide a sample of what #cfhttp.filecontent# is in this sample?


<!--- Send HTTP request for file from intranet and serve file to user--->
<cfhttp method="get" url=" http://domain/load_doc.cfm?doc=#url.doc#"
timeout="60" throwonerror="yes"></cfhttp>
</cfsilent>
<!--- Set default headers for serving file and serve file up to user--->
<cfheader name="Content-Type" value="pdf">
<cfheader name="Content-Disposition" value="attachment; filename=#url.doc#">
<cfcontent type="application/pdf">

<cfoutput>#cfhttp.filecontent#</cfoutput>

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Jul 11, 2006 Jul 11, 2006

Copy link to clipboard

Copied

cfhttp.filecontent is simply the data returned from the cfhttp call. I can
post the big binary data dump if you want, but that is what the variable
contains.

The reason I'm doing this is because we have the files stored one server but
need them to be accessible from two separate servers. I wanted to use a web
service as it reduces the amount of code involved.

Thanks so much for all the effort you have put into this, I know I have been
banging my head against it for a while now.

--
Bryan Ashcraft (remove brain to reply)
Web Application Developer
Wright Medical Technologies, Inc.
------------------------------------------------------------------
Macromedia Certified Dreamweaver Developer
Adobe Community Expert (DW) :: http://www.adobe.com/communities/experts/


"Ian Skinner" <ian.skinner@bloodsource.org> wrote in message
news:e9164l$o5d$1@forums.macromedia.com...
> Can you provide a sample of what #cfhttp.filecontent# is in this sample?
>
>
> <!--- Send HTTP request for file from intranet and serve file to user--->
> <cfhttp method="get" url=" http://domain/load_doc.cfm?doc=#url.doc#"
> timeout="60" throwonerror="yes"></cfhttp>
> </cfsilent>
> <!--- Set default headers for serving file and serve file up to user--->
> <cfheader name="Content-Type" value="pdf">
> <cfheader name="Content-Disposition" value="attachment;
> filename=#url.doc#">
> <cfcontent type="application/pdf">
>
> <cfoutput>#cfhttp.filecontent#</cfoutput>


Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Jul 11, 2006 Jul 11, 2006

Copy link to clipboard

Copied

A small sample of the data dump would be fine, I was just curious if it
was an obvious encoding?

I am making a bit of progress, there is an error in the code, and the
error display is what is being downloaded to the reader.

Bash **AdobeCommunityExpert** wrote:
> cfhttp.filecontent is simply the data returned from the cfhttp call. I can
> post the big binary data dump if you want, but that is what the variable
> contains.
>
> The reason I'm doing this is because we have the files stored one server but
> need them to be accessible from two separate servers. I wanted to use a web
> service as it reduces the amount of code involved.
>
> Thanks so much for all the effort you have put into this, I know I have been
> banging my head against it for a while now.
>

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Jul 11, 2006 Jul 11, 2006

Copy link to clipboard

Copied

Well if one tries hard enough one can do most anything. The following
code is serving up PDF files from a web service! For some reason, I
could not get this to work by sending the data directly to the client
with the cfcontent tag, but by writing the data to a temp file and then
sending that file to the client with cfcontent worked.

Hopefully you can build on this to solve your problem.

fileServing.cfm
---------------
<cfset myFile="test.pdf">

<cfheader name="Content-Type" value="pdf">
<cfheader name="Content-Disposition" value="attachment; filename=#Myfile#">

<cfset testObj = createObject("webservice",
" http://playground/probono/fileServing.cfc?wsdl")>

<cffile action="write" file="g:\playground\probono\tempServe.pdf"
output="#BinaryDecode(testObj.serveFile(myFile),'Base64')#"
addnewline="No" >

<cfcontent type="application/pdf"
file="g:\playground\probono\tempServe.pdf" reset="no">


fileServing.cfc
---------------
<cfcomponent>
<cffunction name="serveFile" access="remote" returntype="string">
<cfargument name="fileToServe" required="yes" type="string">

<cfset var fileObj = "">
<cfset var returnVar = "">
<cfset var file = "">

<cffile action="readBinary"
file="g:\playground\probono\#arguments.fileToServe#" variable="fileObj">
<cfset returnVar = binaryEncode(fileObj,"Base64")>

<cfreturn returnVar>
</cffunction>
</cfcomponent>

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Jul 11, 2006 Jul 11, 2006

Copy link to clipboard

Copied

You rock!!!!

Thank you so much. I'll just have to save it, serve it, delete it!

--
Bryan Ashcraft (remove brain to reply)
Web Application Developer
Wright Medical Technologies, Inc.
------------------------------------------------------------------
Macromedia Certified Dreamweaver Developer
Adobe Community Expert (DW) :: http://www.adobe.com/communities/experts/


"Ian Skinner" <ian.skinner@bloodsource.org> wrote in message
news:e9196n$rj2$1@forums.macromedia.com...
> Well if one tries hard enough one can do most anything. The following
> code is serving up PDF files from a web service! For some reason, I could
> not get this to work by sending the data directly to the client with the
> cfcontent tag, but by writing the data to a temp file and then sending
> that file to the client with cfcontent worked.
>
> Hopefully you can build on this to solve your problem.
>
> fileServing.cfm
> ---------------
> <cfset myFile="test.pdf">
>
> <cfheader name="Content-Type" value="pdf">
> <cfheader name="Content-Disposition" value="attachment;
> filename=#Myfile#">
>
> <cfset testObj = createObject("webservice",
> " http://playground/probono/fileServing.cfc?wsdl")>
>
> <cffile action="write" file="g:\playground\probono\tempServe.pdf"
> output="#BinaryDecode(testObj.serveFile(myFile),'Base64')#"
> addnewline="No" >
>
> <cfcontent type="application/pdf"
> file="g:\playground\probono\tempServe.pdf" reset="no">
>
>
> fileServing.cfc
> ---------------
> <cfcomponent>
> <cffunction name="serveFile" access="remote" returntype="string">
> <cfargument name="fileToServe" required="yes" type="string">
>
> <cfset var fileObj = "">
> <cfset var returnVar = "">
> <cfset var file = "">
>
> <cffile action="readBinary"
> file="g:\playground\probono\#arguments.fileToServe#" variable="fileObj">
> <cfset returnVar = binaryEncode(fileObj,"Base64")>
>
> <cfreturn returnVar>
> </cffunction>
> </cfcomponent>


Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Jul 11, 2006 Jul 11, 2006

Copy link to clipboard

Copied

I just thought of something of which you should be aware. I believe
there is a potential for a race condition during your save it, serve it,
delete it cycle.

I suspect you will want to lock or otherwise control the access to this
logic so that a second user is not saving a new file just before an
earlier user is to be served and thus they both get the second user's file.

Bash **AdobeCommunityExpert** wrote:
> You rock!!!!
>
> Thank you so much. I'll just have to save it, serve it, delete it!
>

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Jul 12, 2006 Jul 12, 2006

Copy link to clipboard

Copied

Very good point. I was planning using the makeunique option of cffile to
help with that. Adding a lock could further enhance this. Thanks!

--
Bryan Ashcraft (remove brain to reply)
Web Application Developer
Wright Medical Technologies, Inc.
------------------------------------------------------------------
Macromedia Certified Dreamweaver Developer
Adobe Community Expert (DW) :: http://www.adobe.com/communities/experts/


"Ian Skinner" <ian.skinner@bloodsource.org> wrote in message
news:e91a6t$soo$1@forums.macromedia.com...
>I just thought of something of which you should be aware. I believe there
>is a potential for a race condition during your save it, serve it, delete
>it cycle.
>
> I suspect you will want to lock or otherwise control the access to this
> logic so that a second user is not saving a new file just before an
> earlier user is to be served and thus they both get the second user's
> file.
>
> Bash **AdobeCommunityExpert** wrote:
>> You rock!!!!
>>
>> Thank you so much. I'll just have to save it, serve it, delete it!
>>


Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Jul 12, 2006 Jul 12, 2006

Copy link to clipboard

Copied

Apparently these servers just don't like me. I get the binary data dumped on
the page using your method.

Basically I get a lot of this stuff:

%PDF-1.2 %?? 12 0 obj << /Length 13 0 R /Filter /FlateDecode >> stream
H?????????%=??6$Y`'??`gl??? ???\V????
TF??=O??2#fS??(?X?o??1#???&k????z?@v
?'?8??5`qo!.?=??7???+????????Rf??
????h?????�f?w??L!????????2{WwU?? \??fkB???]???!????? iw??]???Cg? ??
sf???;?P???0????~Ig3h??

--
Bryan Ashcraft (remove brain to reply)
Web Application Developer
Wright Medical Technologies, Inc.
------------------------------------------------------------------
Macromedia Certified Dreamweaver Developer
Adobe Community Expert (DW) :: http://www.adobe.com/communities/experts/


"Ian Skinner" <ian.skinner@bloodsource.org> wrote in message
news:e9196n$rj2$1@forums.macromedia.com...
> Well if one tries hard enough one can do most anything. The following
> code is serving up PDF files from a web service! For some reason, I could
> not get this to work by sending the data directly to the client with the
> cfcontent tag, but by writing the data to a temp file and then sending
> that file to the client with cfcontent worked.
>
> Hopefully you can build on this to solve your problem.
>
> fileServing.cfm
> ---------------
> <cfset myFile="test.pdf">
>
> <cfheader name="Content-Type" value="pdf">
> <cfheader name="Content-Disposition" value="attachment;
> filename=#Myfile#">
>
> <cfset testObj = createObject("webservice",
> " http://playground/probono/fileServing.cfc?wsdl")>
>
> <cffile action="write" file="g:\playground\probono\tempServe.pdf"
> output="#BinaryDecode(testObj.serveFile(myFile),'Base64')#"
> addnewline="No" >
>
> <cfcontent type="application/pdf"
> file="g:\playground\probono\tempServe.pdf" reset="no">
>
>
> fileServing.cfc
> ---------------
> <cfcomponent>
> <cffunction name="serveFile" access="remote" returntype="string">
> <cfargument name="fileToServe" required="yes" type="string">
>
> <cfset var fileObj = "">
> <cfset var returnVar = "">
> <cfset var file = "">
>
> <cffile action="readBinary"
> file="g:\playground\probono\#arguments.fileToServe#" variable="fileObj">
> <cfset returnVar = binaryEncode(fileObj,"Base64")>
>
> <cfreturn returnVar>
> </cffunction>
> </cfcomponent>


Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Jul 12, 2006 Jul 12, 2006

Copy link to clipboard

Copied

Apparently this is an IE issue as it works fine FF.

--
Bryan Ashcraft (remove brain to reply)
Web Application Developer
Wright Medical Technologies, Inc.
------------------------------------------------------------------
Macromedia Certified Dreamweaver Developer
Adobe Community Expert (DW) :: http://www.adobe.com/communities/experts/


"Bash **AdobeCommunityExpert**" <bashcraft@wmtBRAIN.com> wrote in message
news:e93fdq$jfs$1@forums.macromedia.com...
> Apparently these servers just don't like me. I get the binary data dumped
> on the page using your method.
>
> Basically I get a lot of this stuff:
>
> %PDF-1.2 %?? 12 0 obj << /Length 13 0 R /Filter /FlateDecode >> stream
> H?????????%=??6$Y`'??`gl??? ???\V????
> TF??=O??2#fS??(?X?o??1#???&k????z?@v
> ?'?8??5`qo!.?=??7???+????????Rf??
> ????h?????�f?w??L!????????2{WwU?? \??fkB???]???!????? iw??]???Cg?
> ?? sf???;?P???0????~Ig3h??
>
> --
> Bryan Ashcraft (remove brain to reply)
> Web Application Developer
> Wright Medical Technologies, Inc.
> ------------------------------------------------------------------
> Macromedia Certified Dreamweaver Developer
> Adobe Community Expert (DW) :: http://www.adobe.com/communities/experts/
>
>
> "Ian Skinner" <ian.skinner@bloodsource.org> wrote in message
> news:e9196n$rj2$1@forums.macromedia.com...
>> Well if one tries hard enough one can do most anything. The following
>> code is serving up PDF files from a web service! For some reason, I
>> could not get this to work by sending the data directly to the client
>> with the cfcontent tag, but by writing the data to a temp file and then
>> sending that file to the client with cfcontent worked.
>>
>> Hopefully you can build on this to solve your problem.
>>
>> fileServing.cfm
>> ---------------
>> <cfset myFile="test.pdf">
>>
>> <cfheader name="Content-Type" value="pdf">
>> <cfheader name="Content-Disposition" value="attachment;
>> filename=#Myfile#">
>>
>> <cfset testObj = createObject("webservice",
>> " http://playground/probono/fileServing.cfc?wsdl")>
>>
>> <cffile action="write" file="g:\playground\probono\tempServe.pdf"
>> output="#BinaryDecode(testObj.serveFile(myFile),'Base64')#"
>> addnewline="No" >
>>
>> <cfcontent type="application/pdf"
>> file="g:\playground\probono\tempServe.pdf" reset="no">
>>
>>
>> fileServing.cfc
>> ---------------
>> <cfcomponent>
>> <cffunction name="serveFile" access="remote" returntype="string">
>> <cfargument name="fileToServe" required="yes" type="string">
>>
>> <cfset var fileObj = "">
>> <cfset var returnVar = "">
>> <cfset var file = "">
>>
>> <cffile action="readBinary"
>> file="g:\playground\probono\#arguments.fileToServe#" variable="fileObj">
>> <cfset returnVar = binaryEncode(fileObj,"Base64")>
>>
>> <cfreturn returnVar>
>> </cffunction>
>> </cfcomponent>
>
>


Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Jul 12, 2006 Jul 12, 2006

Copy link to clipboard

Copied

LATEST
Nevermind had a Acrobat Reader install acting up for some reason. Reinstall
seems to have fixed it.

Thanks Again for all the help Ian!

--
Bryan Ashcraft (remove brain to reply)
Web Application Developer
Wright Medical Technologies, Inc.
------------------------------------------------------------------
Macromedia Certified Dreamweaver Developer
Adobe Community Expert (DW) :: http://www.adobe.com/communities/experts/


"Bash **AdobeCommunityExpert**" <bashcraft@wmtBRAIN.com> wrote in message
news:e93hh6$m1b$1@forums.macromedia.com...
> Apparently this is an IE issue as it works fine FF.
>
> --
> Bryan Ashcraft (remove brain to reply)
> Web Application Developer
> Wright Medical Technologies, Inc.
> ------------------------------------------------------------------
> Macromedia Certified Dreamweaver Developer
> Adobe Community Expert (DW) :: http://www.adobe.com/communities/experts/
>
>
> "Bash **AdobeCommunityExpert**" <bashcraft@wmtBRAIN.com> wrote in message
> news:e93fdq$jfs$1@forums.macromedia.com...
>> Apparently these servers just don't like me. I get the binary data dumped
>> on the page using your method.
>>
>> Basically I get a lot of this stuff:
>>
>> %PDF-1.2 %?? 12 0 obj << /Length 13 0 R /Filter /FlateDecode >> stream
>> H?????????%=??6$Y`'??`gl??? ???\V????
>> TF??=O??2#fS??(?X?o??1#???&k????z?@v
>> ?'?8??5`qo!.?=??7???+????????Rf??
>> ????h?????�f?w??L!????????2{WwU?? \??fkB???]???!????? iw??]???Cg?
>> ?? sf???;?P???0????~Ig3h??
>>
>> --
>> Bryan Ashcraft (remove brain to reply)
>> Web Application Developer
>> Wright Medical Technologies, Inc.
>> ------------------------------------------------------------------
>> Macromedia Certified Dreamweaver Developer
>> Adobe Community Expert (DW) :: http://www.adobe.com/communities/experts/
>>
>>
>> "Ian Skinner" <ian.skinner@bloodsource.org> wrote in message
>> news:e9196n$rj2$1@forums.macromedia.com...
>>> Well if one tries hard enough one can do most anything. The following
>>> code is serving up PDF files from a web service! For some reason, I
>>> could not get this to work by sending the data directly to the client
>>> with the cfcontent tag, but by writing the data to a temp file and then
>>> sending that file to the client with cfcontent worked.
>>>
>>> Hopefully you can build on this to solve your problem.
>>>
>>> fileServing.cfm
>>> ---------------
>>> <cfset myFile="test.pdf">
>>>
>>> <cfheader name="Content-Type" value="pdf">
>>> <cfheader name="Content-Disposition" value="attachment;
>>> filename=#Myfile#">
>>>
>>> <cfset testObj = createObject("webservice",
>>> " http://playground/probono/fileServing.cfc?wsdl")>
>>>
>>> <cffile action="write" file="g:\playground\probono\tempServe.pdf"
>>> output="#BinaryDecode(testObj.serveFile(myFile),'Base64')#"
>>> addnewline="No" >
>>>
>>> <cfcontent type="application/pdf"
>>> file="g:\playground\probono\tempServe.pdf" reset="no">
>>>
>>>
>>> fileServing.cfc
>>> ---------------
>>> <cfcomponent>
>>> <cffunction name="serveFile" access="remote" returntype="string">
>>> <cfargument name="fileToServe" required="yes" type="string">
>>>
>>> <cfset var fileObj = "">
>>> <cfset var returnVar = "">
>>> <cfset var file = "">
>>>
>>> <cffile action="readBinary"
>>> file="g:\playground\probono\#arguments.fileToServe#" variable="fileObj">
>>> <cfset returnVar = binaryEncode(fileObj,"Base64")>
>>>
>>> <cfreturn returnVar>
>>> </cffunction>
>>> </cfcomponent>
>>
>>
>
>


Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Resources
Documentation