Reputation: 11
Edit: I was able to solve it, but not sure it is very elegant.
Originally, I was building the ICS content (calCreated), then outputing that after a cfheader and cfcontent tag. Here is what I came up with:
<cfset tempFile = getTempDirectory() & 'cal.ics'>
<cffile action="write" file="#tempFile#" output="#calCreated#" fixnewline="No">
<cffile action="readBinary" file="#tempFile#" variable="calBinary">
<cfcontent type="text/calendar" reset="Yes" variable="#calBinary#">
<cfheader name="Content-Disposition" value="attachment; filename=CalendarItem.ics">
The only oddity is, as you can see, I have the filename specified, but it uploads calendarcreator.ics (the script file is calendarcreator.cfm) instead of the specified name.
Thanks for the responses and I would welcome any thoughts on the code.
Original post: I have a script that creates a .ics file, which worked fine until I moved to application.cfc, which adds a character to the end of the file. With that extra space, IOS will not recognize the file and won't open it.
I welcome any thoughts on how I can eliminate that space or on getting IOS to recognize the file.
I changed the output for the onRequest function in application.cfc to void, but it still adds that extra character.
Upvotes: 0
Views: 80
Reputation: 484
What is the character-encoding of calCreated? I ask because, with <cffile action="write" file="#tempFile#" output="#calCreated#" fixnewline="No">
you are apparently writing text content to file. However, you are then reading it back as binary. Just a thought.
In any case, here's what I think might solve the problem: use the attribute output="false"
for the functions onRequestStart and onRequest and for any other functions involved in generating the content.
Upvotes: 0
Reputation: 457
I think both ACF and Lucee have whitespace auto-trimming options - Lucee, for sure.
Upvotes: 0