Hi Roland,
   Thanks for your reply. Yes, I also tried sending the plain file
without the AudioStream. Still it was not received at the server. I am
using the setRequestEntity method since setRequestBody is deprecated. Do
you think that might be a problem?


After making several attempts, I finally switched to something without
using HttpClient, i.e. I used URL, URLConnection and OutputStream to
write the audio data to the stream. I see that it gets received at the
server meaning it shows the content length correctly. But when I try to
perform a read on the stream, it always returns -1. 

I am not sure what is the cause of the problem. Following is the code
snipped on the server.

          ServletInputStream fin = request.getInputStream();           
          FileOutputStream fout = new
FileOutputStream("c:"+System.getProperty("file.separator")+"ringtone.wav
");
          byte[] buff = new byte[1024*16];  
          
          int r = fin.read(buff);       
           
          System.out.println("r is::"+r);
          while(r!=-1) {           
          fout.write(buff,0,r);          
          r = fin.read(buff);            
          }

          response.setContentType("audio/x-wav");
          response.getWriter().println("ok\nSaved");
          fout.close();
          fin.close();  

I would highly appreciate if someone can point at the problem.

Thanks/Niti

-----Original Message-----
From: Roland Weber [mailto:[EMAIL PROTECTED] 
Sent: Thursday, February 01, 2007 12:55 AM
To: HttpClient User Discussion
Subject: Re: Problem using PostMethod

Hi Niti,

have you tried to send the file directly, without the AudioInputStream?
The rest of your code looks OK on a quick glance. Except that the
releaseConnection call is not in a finally{} block, but that is not the
cause of your problem.

cheers,
  Roland


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

Reply via email to