Hi,
I have a problem opening a video file in a browser through an application.
Techhologies used are servlets and templates
Here is the flow for ur understanding.
I have a link in a template clicking on which calls a javascript(openWindow)taking the url as parameter)Before opening the file the following process takes place.
Reads the file from the database and stores it in a filestore(some folder in server)
//Write the file from BLOB (taking the file data from database)
and then stores it in filestore by taking fileID and filepath.fileIdentifier is the filename.
File oFile = new File(filePath + "/" + fileIdentifier);
out = new BufferedOutputStream(new FileOutputStream(oFile),
bufferSize);
//create byte buffer and start reading the file
byte[] b = new byte[bufferSize];
int count = in.read(b, 0, bufferSize);
logger.debug("Writing file now");
while (count != -1) {
logger.debug(".");
out.write(b, 0, count);
count = in.read(b, 0, (int) bufferSize);
} // end count!=-1
logger.debug("Complete");
out.flush();
out.close();
out = null;
in.close();
in = null;
After all this process it opens a new window displaying the content of the file
This is all working fine for text files, docs and images but is not the case for opening an audio and video file. For video file ,it opens a new window displaying junk text.
Here is the javascript called on clicking the link in the template.
function openFileinWindow(url, width, menubar){
if(!window.window2){
// has not yet been defined
window2=window.open(url,'new1','menubar=' + menubar + ',toolbar=yes,scrollbars=yes,width=' + width + ',height=450');
// window2=window.open(url);
}
else{
//has been defined
if(!window2.closed){
// still open
window2.close();
}
window2=window.open(url,'new1','menubar=' + menubar + ',toolbar=yes,scrollbars=yes,width=' + width + ',height=450');
}
}
Could you please help me out in this topic?
Thank you