[prev in list] [next in list] [prev in thread] [next in thread]
List: myfaces-dev
Subject: Re: [Trinidad] File upload issue
From: Jeanne Waldman <jeanne.waldman () oracle ! com>
Date: 2011-08-30 1:49:33
Message-ID: 4E5C41AD.2070302 () oracle ! com
[Download RAW message or body]
Hi Jason,
Did you create a JIRA issue for this yet along with your use case?
Thanks,
Jeanne
Jason Lee wrote, On 8/23/2011 8:42 AM PT:
> I have been trying to get tr:inputFile to work, but I keep getting EOFExceptions. \
> I traced it down to MultipartFormHandler._skipBoundary(). The first issue is the \
> EOFException, as noted in the comment, is a horribly misleading exception. :) The \
> reason the exception was thrown, though, seems to be a problem with the boundary \
> handling.
> In _parseBoundary(), contentType might be passed something like \
> "multipart/form-data; \
> boundary=---------------------------135858097916243791492128236579;charset=UTF-8". \
> However, when _skipBoundary() is called, _readLine() returns \
> "-----------------------------135858097916243791492128236579". Note that the first \
> string has ";charset=UTF-8" at the end, while the second does not. It seems that \
> ExternalContext.getContentType() appends that for reason (I'm posting from a \
> Facelets page with the encoding set to UTF-8 ("<?xml version='1.0' encoding='UTF-8' \
> ?>"), so that might be the case.
> At any rate, I made the following changes that seems to allow the uploads to work \
> as expected (as well as throwing what seems to me be a more reasonable Exception, \
> though it could use i18n help).
> Is there a chance we could get this change reviewed and committed? Or perhaps a \
> better explanation of/fix for what we're seeing?
> Thanks! :)
>
> Index: trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/share/util/MultipartFormHandler.java
> ===================================================================
> --- trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/share/util/MultipartFormHandler.java \
> (revision 1160712)
> +++ trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/share/util/MultipartFormHandler.java \
> (working copy) @@ -225,7 +225,7 @@
> if (!line.startsWith(_boundary))
> {
> // A better exception would be nice.
> - throw new EOFException();
> + throw new IllegalStateException("Boundary information not found. Unable to \
> process upload."); }
> }
>
> @@ -388,9 +388,14 @@
> {
> return null;
> }
> + String boundary = contentType.substring(boundaryStart + \
> _BOUNDARY_PARAMETER.length()); + final int semicolonIndex = \
> boundary.indexOf(";"); + if (semicolonIndex > -1) {
> + boundary = boundary.substring(0, semicolonIndex);
> + }
>
> // Boundary always starts with "--"
> - return "--" + contentType.substring(boundaryStart + \
> _BOUNDARY_PARAMETER.length()); + return "--" + boundary;
> }
>
> //Reads the ContentType string out of a line of the incoming request
>
>
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic