Hi all,

I have been googling for many hours trying to find some info on how to do this..

What I have is a php uploader example for posting videos to a (ooyala.com) server.
My app has a tomcat backend with various servlets for doing POSTS, PUTS, etc..

I need to port the php/curl sample code over to a servlet.

This is the working php code:

<?php  
        $content = file_get_contents('upload-test.mov'); //my video file I want to upload  
        $size = filesize('upload-test.mov');  
 
        $url=   "http://uploader-v2.ooyala.com/send?filename=ZnbWx5ZDpwWdaM-3J8FrsHMInZJYZDaU/0000000000000-0000001241337&filesize=1241338&expires=1377675871&signature=SHELBO3USSyBtCHtHFP9zhjWLqdq6iOwx+NJOJjlVIk";  
        $ch = curl_init($url);  
        curl_setopt ($ch, CURLOPT_RETURNTRANSFER, true);  
        curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);  
        curl_setopt ($ch, CURLOPT_HTTPHEADER, Array("Content-Type: multipart/mixed"));  
        curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "PUT");  
        curl_setopt($ch, CURLOPT_POSTFIELDS, $content);  
 
        try {  
                return httpRequest($ch);  
        } catch (Exception $e) {  
                throw $e;  
        }  
 
        function httpRequest($ch)  
        {  
                curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);  
                $response = curl_exec($ch);  
 
                if($response){  
                    echo $response;  
                }  
 
                if(curl_error($ch))  
                {  
                        curl_close($ch);  
                        return curl_error($ch);  
                }  
 
                $head=curl_getinfo($ch);  
                $content = $head["content_type"];  
                $code = $head["http_code"];  
                curl_close($ch);  
        }


But I am confused hot to acomplish this with HttpPut in my servlet because I dont know how to attach the video data.
Heres my servlet code:

protected void doPost( HttpServletRequest theReq, HttpServletResponse theResp )  
                            throws ServletException, IOException  
    {  
        String uri = theReq.getParameter("uri"); //this is where I'd put my url... but how do i attach the video stream?  
 
                //for the return result string  
        PrintWriter out = theResp.getWriter();  
 
        DefaultHttpClient hc = new DefaultHttpClient();  
 
        HttpPut p = new HttpPut(uri);  
 
        //send the data  
        try {  
//how do i link my video to the request???  
            p.setHeader("Content-type", "application/json");  
            HttpResponse response = hc.execute(p);            
 
        } catch (Exception e) {  
            e.printStackTrace();  
        }  
    }

But I am confused how to acomplish this with HttpPut in my servlet because I dont know how to attach the video data.
Heres my servlet code:

All I really need is help with how to port that php/curl code to a java servlet..
I hope someone in here can help me, I will be truly grateful!!

Thanks in advance,

-Tavis