commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Martin Cooper <mart...@apache.org>
Subject Re: Many attachments, one name
Date Thu, 09 Feb 2006 06:29:56 GMT
On 2/8/06, Greg Evetts <greg@evetts.org> wrote:
>
> It seems to me that the bug is the failure to persist the field name
> ("pics" in this example) and apply it to subsequent attachments within
> this multipart/mixed segment.  I think that to overload the "filename"
> by giving it "field name" semantics is incorrect.


Sorry, yes, you're right. Please file a bug report in Bugzilla to make sure
this doesn't get lost.

To answer your question regarding the client-side, I've written an
> applet generates the request. I can send you the source if you're
> interested.


Yes please. That would be very helpful. Thanks!

--
Martin Cooper


-Greg Evetts
>
> On 2/8/06, Martin Cooper <martinc@apache.org> wrote:
> > On 2/8/06, Greg Evetts <greg@evetts.org> wrote:
> > >
> > > I'm having a problem parsing this example multipart request from RFC
> > > 1867. It appears that the attachmements "file1.txt" and "file2.gif"
> > > are associates with the same form field name, "pics". However, since
> > > the name "pics" is specified in the content-disposition header on line
> > > [08], it is lost when the content-disposition header on line [12] is
> > > parsed. The attachment is returned in the FileItem but the fieldName
> > > property is null.
> >
> >
> > There are two separate issues here. The first is that FileUpload will
> only
> > retain the name of individual items, and not the collective name given
> to
> > multipart/mixed data, so you should not expect "pics" to show up
> anywhere in
> > the results. The second issue is that FileUpload is not picking up the
> > filename from an attachment as the field name. That's probably a bug, so
> it
> > would be good if you could file a bug report against it in Bugzilla.
> >
> > To be honest, the whole multipart/mixed thing hardly ever comes up, and
> so
> > hasn't had much attention paid to it. Can you tell me how you generated
> the
> > request that you're trying to parse?
> >
> > --
> > Martin Cooper
> >
> >
> > [01] Content-type: multipart/form-data, boundary=AaB03x
> > > [02]
> > > [03] --AaB03x
> > > [04] content-disposition: form-data; name="field1"
> > > [05]
> > > [06] Joe Blow
> > > [07] --AaB03x
> > > [08] content-disposition: form-data; name="pics"
> > > [09] Content-type: multipart/mixed, boundary=BbC04y
> > > [10]
> > > [11] --BbC04y
> > > [12] Content-disposition: attachment; filename="file1.txt"
> > > [13] Content-Type: text/plain
> > > [14]
> > > [15] ... contents of file1.txt ...
> > > [16] --BbC04y
> > > [17] Content-disposition: attachment; filename="file2.gif"
> > > [18] Content-type: image/gif
> > > [19] Content-Transfer-Encoding: binary
> > > [20]
> > > [21] ...contents of file2.gif...
> > > [22] --BbC04y--
> > > [23] --AaB03x--
> > >
> > > Here's the code I'm using to parse the request:
> > >
> > > [01] final FileItemFactory factory = new DiskFileItemFactory(1024,
> > > TMPDIR);
> > > [02] final ServletFileUpload upload = new ServletFileUpload(factory);
> > > [03]
> > > [04] upload.setSizeMax(1 << 22); // 4MB
> > > [05]
> > > [06] final List<FileItem> items = upload.parseRequest(request_);
> > > [07]
> > > [08] for (final FileItem fi : items) {
> > > [09]   final String name = fi.getFieldName();
> > > [10]   ...
> > > [11] }
> > >
> > > Any help is appreciated.
> > > -Greg Evetts
> > >
> > > ---------------------------------------------------------------------
> > > To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
> > > For additional commands, e-mail: commons-user-help@jakarta.apache.org
> > >
> > >
> >
> >
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: commons-user-help@jakarta.apache.org
>
>

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message