commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Greg Evetts <g...@evetts.org>
Subject Many attachments, one name
Date Wed, 08 Feb 2006 17:21:57 GMT
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.

[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


Mime
View raw message