[ColdBox 3.8] How to render binary content with a filename? RenderData()?

I need to do something like this:

<cfheader name=“Content-Disposition” value=“inline; filename=”"#docData.filename#""" />

Right now I have that in my controller, which is probably not the right place for it? I could create a view and put it in there, but I don’t like going around the framework with my own cfheader & cfcontent tags. I was thinking I should be able to just handle this all with RenderData()? But I can’t get it to work. This throws an error:

<cfset arguments.event.renderData(data=docData.binaryFileContent, contentType=docData.mimetype) />

Returns: ByteArray objects cannot be converted to strings

And I still don’t see how to set the filename or the content-disposition.

Thanks,
-Ryan

renderData() has an isBinary argument, set it to true. Did you read the API
Docs :slight_smile:

Luis F. Majano
CEO
Ortus Solutions, Corp

ColdBox Platform: http://www.coldbox.org
Linked In: http://www.linkedin.com/pub/3/731/483
Blog: http://www.luismajano.com
IECFUG Manager: http://www.iecfug.com
Social: twitter.com/lmajano facebook.com/lmajano

Thanks, that helped. Sorry no I did not find the API docs, I googled, found the wiki, looked all over the wiki, searched the wiki, but didn’t see the isBinary attribute.

Unfortunately this still won’t work for me because the file is downloaded as “index.pdf”. I would like to suggest a future enhancement of being able to specify the Content-Disposition.

Thanks.

For reference, the API docs are a link in the coldbox.org main nav:
http://www.coldbox.org/api

You can browse or download HTML javadoc style docs, or my favorite is to click the “quickdocs” link and use the search in the upper right hand corner. For instance, type “renderData” and click the result that is part of the requestContext and you’ll see all the parameters.

Of course, since that data is pulled straight from the source, I’ll often times just open the file from the Coldbox.system folder and look at the code :slight_smile:

Regarding your content-disposition, can you set that header manually for now before calling render data?

Thanks!

~Brad

ColdBox Platform Evangelist
Ortus Solutions, Corp

E-mail: brad@coldbox.org
ColdBox Platform: http://www.coldbox.org
Blog: http://www.codersrevolution.com

Brad thanks for the tips. And that is a good idea to manually set the Content-Disposition header and then use RenderData() afterwards, I will use it. I still think it would be nice to be able to say:

renderData(isBinary=true, data=myData, contentType=mimetype, filename=“export.xls”, inline=true)

or something like that.

http://blog.coldbox.org/blog/how-to-create-a-jira-account-and-enter-coldbox-tickets

:slight_smile:

Thanks!

~Brad

ColdBox Platform Evangelist
Ortus Solutions, Corp

E-mail: brad@coldbox.org
ColdBox Platform: http://www.coldbox.org
Blog: http://www.codersrevolution.com