You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by Adam Henderson Azudio <az...@hotmail.com> on 2005/07/13 16:19:38 UTC

File Upload Component & MP4 files

I'm trying to upload mp4 files to my app but when I view them in the  
page the video is missing but the audio is ok.

I appreciate the fact that movie/mp4 files can be incredibly  
complicated in structure but I wondered if anybody knew a way to do  
this or if anybody had any success in uploading mp4s.

Here is my code in my upload listener:

                 // ** Handle Movies
                 log.debug("Handling a mp4");

                 // Build filename for movie
                 fileName = getMedia().getGuid() + ".mp4";

                 // Write the file to the File System
                 InputStream stream = uploadedFile.getStream();

                 OutputStream bos;
                 try {
                     bos = new FileOutputStream(uploadDir + "/" +  
fileName);

                     int bytesRead = 0;
                     byte[] buffer = new byte[8192];

                     while ((bytesRead = stream.read(buffer, 0,  
8192)) != -1) {
                         bos.write(buffer, 0, bytesRead);
                     }

                     bos.close();

                     //close the stream
                     stream.close();

                 } catch (IOException e) {
                     e.printStackTrace();
                 }

I'm not terribly oufait with file reading & writing, but I'm guessing  
it has something to do with writing the file back to the filesystem.

Any ideas?

Adam


---------------------------------------------------------------------
To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tapestry-user-help@jakarta.apache.org