--
FYI --
Apparently, there are bugs in at least one implemenation of file upload
(User-Agent: Mozilla/4.0 (compatible; MSIE 4.5; Mac_PowerPC) ... to see a
sample implementation which works around that browser's bugs, you could
checkout GSP, and take a look at 'GspRequest.parseFileUpload()'. This
also handles other form input variables.
You can get GSP at http://www.bitmechanic.com/projects/gsp/ ... it's under
the GPL, so you can't sell something based on it, but you're certainly
welcome to use it otherwise. ;-)
The file upload code was written by James Cooper (he and I are responsible
for GSP, though we haven't had much time to work on it for a while)...
hth --
Ed
On Thu, 8 Jul 1999, Christopher Hoover wrote:
> I gave up trying to cons a MimeMultipart directly, and tried a different
> approach.
>
> This approach is quite clean. The trick is to use the MimeMessage interface
> that takes an InputStream. But to use this interface you need to dummy up a
> message header that contains at a minimum the content type:
>
> import javax.mail.*;
> import javax.mail.internet.*;
>
> // ...
>
> Properties props = System.getProperties();
> Session session = Session.getDefaultInstance(props, null);
>
> // Dummy up a message header.
> String headers
> = "Content-Type: " + request.getContentType() +
> "\r\n\r\n";
>
> InputStream messageIS =
> new SequenceInputStream(new
>StringBufferInputStream(headers),
>
>request.getInputStream());
>
> MimeMessage message = new MimeMessage(session, messageIS);
>
> Object content = message.getContent();
> if (content instanceof MimeMultipart) {
> MimeMultipart mm = (MimeMultipart) content;
>
> int nBodyParts = mm.getCount();
> for (int i = 0; i < nBodyParts; i++) {
> BodyPart part = mm.getBodyPart(i);
> ...
> }
> }
>
> Ciao!
> -ch
>
> ------
> Christopher Hoover
> mailto:[EMAIL PROTECTED]
> http://www.murgatroid.com
> +1-408-348-0304, +1-209-315-6378 fax
>
>
> > -----Original Message-----
> > From: [EMAIL PROTECTED]
> > [mailto:[EMAIL PROTECTED]]On Behalf Of Christopher
> > Hoover
> > Sent: Wednesday, July 07, 1999 4:10 PM
> > To: [EMAIL PROTECTED]
> > Subject: Using javax.mail.internet for parsing multipart/form-data
> >
> >
> > --
> >
> >
> > [Slightly off topic ... ]
> >
> > Has anyone had any success using the Java Mail framework
> > (javax.mail.internet) to parse multipart/form-data POST responses?
> >
> > All my attempts thus far have yielded a javax.mail.internet.ParseException
> > when I try to create a MimeMultipart from a DataSource that reads from the
> > request input stream.
> >
> > The Java Mail framework isn't Open Source, so it is difficult to
> > figure out
> > what is going wrong. :-(
> >
> > Ciao!
> > -ch
> >
> > ------
> > Christopher Hoover
> > mailto:[EMAIL PROTECTED]
> > http://www.murgatroid.com
> > +1-408-348-0304, +1-209-315-6378 fax
> >
> >
> >
> >
> > --
> > --------------------------------------------------------------
> > To subscribe: [EMAIL PROTECTED]
> > To unsubscribe: [EMAIL PROTECTED]
> > READ THE FAQ!!!! <http://java.apache.org/faq/>
> > Archives and Other: <http://java.apache.org/main/mail.html/>
> > Problems?: [EMAIL PROTECTED]
> >
>
>
>
> --
> --------------------------------------------------------------
> To subscribe: [EMAIL PROTECTED]
> To unsubscribe: [EMAIL PROTECTED]
> READ THE FAQ!!!! <http://java.apache.org/faq/>
> Archives and Other: <http://java.apache.org/main/mail.html/>
> Problems?: [EMAIL PROTECTED]
>
--
--------------------------------------------------------------
To subscribe: [EMAIL PROTECTED]
To unsubscribe: [EMAIL PROTECTED]
READ THE FAQ!!!! <http://java.apache.org/faq/>
Archives and Other: <http://java.apache.org/main/mail.html/>
Problems?: [EMAIL PROTECTED]