[Building Sakai] Returning binary data (pdf) from Entity Provider?

Aaron Zeckoski azeckoski at unicon.net
Thu Nov 8 12:45:55 PST 2012


You can always get the response and set things on it directly if you
like but the more automatic way would be to use the OutputStream to
dump the content and use the ActionReturn to set the headers and
content type.
actionReturn.encoding and actionReturn.mimeType must be set or it will
try to guess the mimetype itself based on really simple rules that
means it will assume JSON most of the time.

-AZ


On Thu, Nov 8, 2012 at 3:25 PM, Curtis Van-Osch <curtis.van-osch at hec.ca> wrote:
> Hi,
> I'm trying to have a custom action in my EntityProvider send a PDF back to
> the browser.  I've figured out how to get the pdf from
> ContentHostingService, but I can't seem to get any byte data out to the
> client (even a single character or simple string) through an ActionReturn.
>
> You can see the test code I've set up in the attached text file.  Whenever I
> return an ActionReturn with a ByteArrayOuputStream, the client gets a
> response with 0 Content-Length (as seen in firebug) but a success code
> (200).
>
> If I write the data to the OutputStream parameter that is available to the
> custom action it gets sent to the browser, but in that case I cannot see how
> to set the content-type to "application/pdf".
>
> Has anyone tried to do anything similar?  I'd appreciate any input.
>
> --
> Curtis van Osch
> Analyste en informatique
> Service de gestion des technologies de l'information
> HEC Montréal
> 514-340-6000 poste 2029
> curtis.van-osch at hec.ca
>
> _______________________________________________
> sakai-dev mailing list
> sakai-dev at collab.sakaiproject.org
> http://collab.sakaiproject.org/mailman/listinfo/sakai-dev
>
> TO UNSUBSCRIBE: send email to sakai-dev-unsubscribe at collab.sakaiproject.org
> with a subject of "unsubscribe"



-- 
Aaron Zeckoski - Software Architect - http://tinyurl.com/azprofile


More information about the sakai-dev mailing list