Well Antoine...this is truly a sign of a new good year since your little trick just works very well.
Much appreciated here!!! Cheers, happy new year, Arie. On Wed, Dec 31, 2008 at 6:46 PM, Arie Fishler <[email protected]> wrote: > Will try that and report. > > Thanks for the suggestion. > > Cheers, > Arie > > On Wed, Dec 31, 2008 at 4:09 PM, Antoine Angenieux < > [email protected]> wrote: > >> Hi Arie, >> >> I don't know your usecase, but what I usually do when I need to stream >> data through wicket, I use a ResourceStreamRequestTarget along with an >> implementation of AbstractResourceStreamWriter. >> In your AbstractResourceStreamWriter you can onverride de getContentType() >> method as : >> >> @Override >> public String getContentType() { >> return "image/png"; >> } >> >> and when you want to stream your content, just do : >> RequestCycle().get().setRequestTarget( >> new ResourceStreamRequestTarget(new MyResourceStreamWriterImpl()); >> >> Hope this helps ! >> >> Happy new year ;) >> >> Antoine. >> >> Arie Fishler wrote: >> >>> Hi, >>> >>> I am trying to stream an image to the response and setting the proper >>> mime >>> type to it prior to writing the stream to the output. >>> >>> The file exists and is written but the mime type of the response is not >>> set >>> according to what I expect it to be ("image/png"). Any idea? >>> >>> >>> WebResponse response = (WebResponse)getRequestCycle().getResponse(); >>> >>> *if* (imagePath != *null*) { >>> >>> *try* { >>> >>> File imageFile = *new* File(imagePath); >>> >>> FileInputStream inputStream = *new* FileInputStream(imageFile); >>> >>> response.setContentType(*DEFAULT_MIME_TYPE*); >>> >>> Streams.*copy*(inputStream, response.getOutputStream()); >>> >>> *return*; >>> >>> } >>> >>> *catch* (FileNotFoundException e) { >>> >>> } >>> >>> *catch* (IOException e) { >>> >>> } >>> >>> } >>> >>> // 404 >>> >>> response.getHttpServletResponse().setStatus(*NOT_FOUND*); >>> >>> >> -- >> Antoine Angénieux >> Associé >> >> Clinigrid >> 5, avenue Mozart >> 75016 Paris, France >> +336 60 21 09 18 >> [email protected] >> >> >> >> >> --------------------------------------------------------------------- >> To unsubscribe, e-mail: [email protected] >> For additional commands, e-mail: [email protected] >> >> >
