Yep... the file is playable as mp3, but very distorted.. currently I'm
experimenting with the URLEncoder seems to give better results....

----- Original Message -----
From: "Padhu Vinirs" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Friday, November 01, 2002 20:31
Subject: Re: sending a file from Java application to servlet


> So is a new file being created on the server side ?
>
> -- padhu
>
>
>
>
> Peter Maas wrote:
>
> >I tried doing that and it almost works... but... (probably a realy stupid
> >mistake)....
> >I would like to transfer an mp3 file to the servlet this is how the code
in
> >the app looks:
> >
> >    DataOutputStream printout = new
> >DataOutputStream(urlC.getOutputStream());
> >
> >   File theFile = new File(file);
> >   String fname = "filename="+theFile.getName();
> >     printout.writeBytes(fname);
> >     printout.writeBytes("\n");
> >
> >      FileInputStream fos;
> >       DataInputStream ds;
> >      try {
> >         fos = new FileInputStream(file);
> >         ds = new DataInputStream( fos );
> >         byte[] data = new byte[(int)theFile.length()];
> >    ds.readFully(data);
> >    printout.write(data);
> >    ds.close();
> >       fos.close();
> >      }
> >      catch (IOException ioe) {
> >               System.out.println( "IO error: " + ioe );
> >   }
> >
> >     printout.flush();
> >     printout.close();
> >
> >The servlet side's code looks like this:
> >
> >    /**
> >    * Below we extract the filename from the
> >    * Http headers read so far.
> >    */
> >
> >    fFilename =
>
>pLine.substring(9+pLine.lastIndexOf("filename="),pLine.lastIndexOf("mp3")+3
)
> >;
> > System.out.println(fFilename);
> >
> > /*
> >  * Write the remaining to disk
> >  */
> >
> >    FileOutputStream fos;
> >    DataOutputStream ds;
> >    try {
> >       fos = new FileOutputStream(UploadLocation+fFilename);
> >       ds = new DataOutputStream( fos );
> >   String line = br.readLine();
> >   if(line != null){
> >   ds.writeBytes(line);
> >   while((line = br.readLine()) != null){
> >    // if there is a newline in the header it probably came from the
binary
> >data
> >    ds.writeBytes("\n");
> >      ds.writeBytes(line);
> >  }
> >   }
> >      ds.close();
> >      fos.close();
> >    }
> >    catch (IOException ioe) {
> >      System.err.println( "IO error: " + ioe );
> > }
> >
> >----- Original Message -----
> >From: "Padhu Vinirs" <[EMAIL PROTECTED]>
> >To: <[EMAIL PROTECTED]>
> >Sent: Friday, November 01, 2002 14:18
> >Subject: Re: sending a file from Java application to servlet
> >
> >
> >
> >
> >>Why not open a HttpURLConnection to the servlet ? Then you can write to
> >>the url's input stream...
> >>
> >>-- padhu
> >>
> >>
> >>
> >>
> >>>>-----Original Message-----
> >>>>From: Peter Maas [SMTP:[EMAIL PROTECTED]]
> >>>>Sent: 01 November 2002 12:36
> >>>>To:   [EMAIL PROTECTED]
> >>>>Subject:      sending a file from Java application to servlet
> >>>>
> >>>>Hi,
> >>>>
> >>>>I'm trying to figure out how send a file to a servlet from a java
> >>>>application.... what would be the typical way to do this...?
> >>>>
> >>>>P
> >>>>
> >>>>
> >>>>
>
>>>_________________________________________________________________________
_
> >>>
> >>>
> >>>>_
> >>>>To unsubscribe, send email to [EMAIL PROTECTED] and include in the
> >>>>body
> >>>>of the message "signoff SERVLET-INTEREST".
> >>>>
> >>>>Archives: http://archives.java.sun.com/archives/servlet-interest.html
> >>>>Resources:
http://java.sun.com/products/servlet/external-resources.html
> >>>>LISTSERV Help: http://www.lsoft.com/manuals/user/user.html
> >>>>
> >>>>
> >>>>
> >>>>
> >>>--
> >>>
> >>>It is the strict policy of Truworths that its e-mail facility and all
> >>>e-mail communications emanating therefrom, should be utilised for
> >>>business purposes only and should conform to high professional and
> >>>business standards.   Truworths has stipulated certain regulations in
> >>>terms whereof strict guidelines relating to the use and content of
> >>>e-mail communications are laid down. The use of the Truworths e-mail
> >>>facility is not permitted for the distribution of chain letters or
> >>>offensive mail of any nature whatsoever.   Truworths hereby distances
> >>>itself from and accepts no liability in respect of the unauthorised
> >>>use of its e-mail facility or the sending of e-mail communications
> >>>for other than strictly business purposes.   Truworths furthermore
> >>>disclaims liability for any  unauthorised instruction for  which
> >>>permission was not granted.    Truworths Limited accepts no liability
> >>>for any consequences arising from or as a result of reliance on this
> >>>message unless it is in respect of bona fide Truworths business for
> >>>which proper authorisation has been granted.
> >>>
> >>>Any recipient of an unacceptable communication, a chain letter or
> >>>offensive material of any nature is requested to notify the Truworths
> >>>e-mail administrator ([EMAIL PROTECTED]) immediately in order that
> >>>appropriate action can be taken against the individual concerned.
> >>>
> >>>
> >>>
>
>>__________________________________________________________________________
_
> >>
> >>
> >>>To unsubscribe, send email to [EMAIL PROTECTED] and include in the
> >>>
> >>>
> >body
> >
> >
> >>>of the message "signoff SERVLET-INTEREST".
> >>>
> >>>Archives: http://archives.java.sun.com/archives/servlet-interest.html
> >>>Resources: http://java.sun.com/products/servlet/external-resources.html
> >>>LISTSERV Help: http://www.lsoft.com/manuals/user/user.html
> >>>
> >>>
> >>>
> >>>
> >>>
> >>>
> >>
> >>
>
>___________________________________________________________________________
> >
> >
> >>To unsubscribe, send email to [EMAIL PROTECTED] and include in the
> >>
> >>
> >body
> >
> >
> >>of the message "signoff SERVLET-INTEREST".
> >>
> >>Archives: http://archives.java.sun.com/archives/servlet-interest.html
> >>Resources: http://java.sun.com/products/servlet/external-resources.html
> >>LISTSERV Help: http://www.lsoft.com/manuals/user/user.html
> >>
> >>
> >>
> >
>
>___________________________________________________________________________
> >To unsubscribe, send email to [EMAIL PROTECTED] and include in the
body
> >of the message "signoff SERVLET-INTEREST".
> >
> >Archives: http://archives.java.sun.com/archives/servlet-interest.html
> >Resources: http://java.sun.com/products/servlet/external-resources.html
> >LISTSERV Help: http://www.lsoft.com/manuals/user/user.html
> >
> >
> >
> >
>
>
___________________________________________________________________________
> To unsubscribe, send email to [EMAIL PROTECTED] and include in the
body
> of the message "signoff SERVLET-INTEREST".
>
> Archives: http://archives.java.sun.com/archives/servlet-interest.html
> Resources: http://java.sun.com/products/servlet/external-resources.html
> LISTSERV Help: http://www.lsoft.com/manuals/user/user.html
>

___________________________________________________________________________
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff SERVLET-INTEREST".

Archives: http://archives.java.sun.com/archives/servlet-interest.html
Resources: http://java.sun.com/products/servlet/external-resources.html
LISTSERV Help: http://www.lsoft.com/manuals/user/user.html

Reply via email to