Hello Everyone,

Can someone guide me on how to stream video using my struts 2 application.

I have tried using the input stream method described in different thread. while the method is working fine for images, it isn't working for video (flv) file.

I also tried writing the flv file to output stream of the response, but it isn't working either.

try
{
        HttpServletResponse response = ServletActionContext.getResponse();

        OutputStream outputStream = response.getOutputStream();
        File file = new File(filename);
        FileInputStream fileInputStream = new FileInputStream(file);
        byte[] buffer = new byte[1024 * 64];
        int bytesRead;

        response.setContentType("video/x-flv");
response.addHeader("Content-Disposition", "attachment; filename=" + filename);
        response.setContentLength((int) file.length());
        response.addHeader("Cache-Control", "max-age=25");

        while ((bytesRead = fileInputStream.read(buffer)) != -1)
        {
                outputStream.write(buffer, 0, bytesRead);
        }
        fileInputStream.close();

}
catch (Exception e)
{
}
return null;


Regards,
Muhammad Momin Rashid.


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to