In a similar vein to <https://cfml.slack.com/archi...
# cfml-general
r
In a similar vein to https://cfml.slack.com/archives/C06T99N9G/p1712132825112459 I want to open a Word document stored on the server with my local copy of Word. I'm sure I've done this before with a simple
<cfcontent type="application/vnd.openxmlformats-officedocument.wordprocessingml.document" file="./file-sample.docx">
but it tries to save the file locally. I just want to open the document with my local Word app?
a
googles for the
<cfheader>
thing you need to do. Finds answer written by self. https://stackoverflow.com/a/71781957/894061
m
The browsers are finicky beasts and have gone down the path of downloading and forcing to open for a while. Even when providing different values for Content-Disposition. The behavior becomes really unpredictable even with attachment/inline headers and stuff. If you change your Uri you are utilizing Microsoft has provided a custom URI handler to open the documents in the client applications... https://learn.microsoft.com/en-us/office/client-developer/office-uri-schemes Your mileage may vary.
r
Thank you both. I've plainly never really understood the relationship between
<cfheader>
and
<cfcontent>
when displaying non-html files. I've always thought that
<cfcontent>
said "use this app to open the file" in
<cfheader>
I guess I wouldn't expect
inline
to work with a Word doc as I guess the browser doesn't know how to render it like it does with pdf files nowadays. So I guess I can't get the browser to open Word by itself and stream the nominated file to it.
a
All your code can do is suggest. it's the browser's call (and the user who configured it) as to how non-HTML responses are handled. Obvs my answer on S/O is how to inline it. You don't want that, you want to ask it to do the opposite... have a look at what options there are with the
Content-Disposition
header has. But at the end of the day it's not up to you, it's up to the browser.
TBH I'd've thought setting the word mimetype (ie: with
<cfcontent>
, as you have) would be enough. I've got my browser set to NEVER try to open anything in an external app. So you can send all the headers you like, but I'll still just save the file, and then decide what to do with it, thanks.
r
Thanks. I guess it boils down to your last comment in your SO answer, "here, download it and you do something with it" 🙂
✅ 1