commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Joey Garcia <joey.j.gar...@gmail.com>
Subject [fileupload] Upload is discriminating file types
Date Wed, 05 May 2010 14:06:58 GMT
We are writing a new version of our application in GXT (EXT + GWT) and our
old version is classic JSP/Servlets.  In the old system and new system we
use the Apache commons file upload yet we cannot upload text files in our
new version (and zip files) but we can in the old version.  The upload
servlet is pretty much the same in both version.    Now to throw a wrench in
the whole issue, the new system can upload text files when it points to a
different database (demo db), our qa database rejects PDF, JPG and ZIP file
types.  Has anyone ever heard of anything like this?



In the source code of the FileUploadBase class, below is the meat of the
parseRequest method and I bolded the code that prevents the file from being
written to the file system.  When I break point it, it iter.hasNext() is
false on these file types.


    public List /* FileItem */ parseRequest(RequestContext ctx)
>             throws FileUploadException {
>         try {
>             FileItemIterator iter = *getItemIterator(ctx)*;
>             List items = new ArrayList();
>             FileItemFactory fac = getFileItemFactory();
>             if (fac == null) {
>                 throw new NullPointerException(
>                     "No FileItemFactory has been set.");
>             }
>             while *(iter.hasNext()*) {
>                 FileItemStream item = iter.next();
>                 FileItem fileItem = fac.createItem(item.getFieldName(),
>                         item.getContentType(), item.isFormField(),
>                         item.getName());
>                 try {
>                     Streams.copy(item.openStream(),
> fileItem.getOutputStream(),
>                             true);
>                 } catch (FileUploadIOException e) {
>                     throw (FileUploadException) e.getCause();
>                 } catch (IOException e) {
>                     throw new IOFileUploadException(
>                             "Processing of " + MULTIPART_FORM_DATA
>                             + " request failed. " + e.getMessage(), e);
>                 }
>                 if (fileItem instanceof FileItemHeadersSupport) {
>                     final FileItemHeaders fih = item.getHeaders();
>                     ((FileItemHeadersSupport) fileItem).setHeaders(fih);
>                 }
>                 items.add(fileItem);
>             }
>             return items;
>
>

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