I created a REST API that I expose to the consumer. It returns a BLOB (PowerPoint file) and works. BUT the name of the file is simply the method name "GetPowerPoint". I want it to return a custom name like "Exec Summary.pptx".
SEE THE OML attached and skip to the REMINDER note to see what I mean.
Thanks!
Hi Bruce,
if you are accessing the REST endpoint directly you can also add an additional content-disposition header to your response using the AddHeader server action from the HttpRequestHandler module.
Name: content-disposition
Value: attachment; filename=\"mypowerpoint.pptx\"
This tells the browser to download the file using the provided filename. As said. This approach is only applicable when directly access the endpoint url (using the browser).
Additional information for the content-disposition header can be found here: https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Disposition
Best
Stefan
I think you have the wrong idea about how this all works. What you're returning from the REST service is just a stream of binary data. It's not semantically a file, even though it contains a file. So what you should do is, instead of returning the binary data in the body, create a structure that contains both the file body and the file name as attributes, and return that.
Thank you @Kilian Hekhuis and @Stefan Weber! I combined both of your ideas and it is working!Kilian, I actually used the RequestFile structure from the HTTPRequestHandler extension.
Stefan, I then used the AddHeader from the HTTPRequestHandler extension.
Now it works as I had hoped .. a simple REST call returns a well-formed file that is a PowerPoint ready to be consumed.
Glad we could help :)