I’m working on a spreadsheet library and want to stream the created content result. Currently I can successfully create a media content and then create a attachment url that can be used to download the resource. But The best solution would be able to stream the response immediately.
You can return the stream by setting it in the body property of the response:
var stream = getSpreadsheetStream();
return {
body: stream
}
If the spreadsheet file comes from a Java lib, the best is to convert it or wrap it as a ByteSource object. Returning an object of type byte[] would also works but is probably less efficient.
Also, if you set xls or xlsx as the name in the content-disposition you should not have to specify the contentType? Bit unsure about this but there is a default mimeType list in XP for this (I hope…).
Actually, the contentType property is just a shortcut to setting the “Content-Type” header.