You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@commons.apache.org by "vaishali dolas (JIRA)" <ji...@apache.org> on 2008/12/15 06:59:44 UTC

[jira] Created: (FILEUPLOAD-170) problem in parseRequest method of

problem in parseRequest method of 
----------------------------------

                 Key: FILEUPLOAD-170
                 URL: https://issues.apache.org/jira/browse/FILEUPLOAD-170
             Project: Commons FileUpload
          Issue Type: Bug
         Environment: OS: fedora7
IDE:Netbeans
            Reporter: vaishali dolas


I'm facing problem to build progressbar while file uploading
the code snippet is here

// Create a factory for disk-based file items
FileItemFactory factory = new DiskFileItemFactory();

// Create a new file upload handler
ServletFileUpload upload = new ServletFileUpload(factory);

// Parse the request
List   items = upload.parseRequest(request);
In items i'm always getting null


-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (FILEUPLOAD-170) problem in parseRequest method of

Posted by "Jochen Wiedmann (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/FILEUPLOAD-170?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12656557#action_12656557 ] 

Jochen Wiedmann commented on FILEUPLOAD-170:
--------------------------------------------

Looking through the code of FileUploadBase.parseRequest, I can think of no possibility how this could return null. Are you using another version than commons-fileupload 1.2.x?


> problem in parseRequest method of 
> ----------------------------------
>
>                 Key: FILEUPLOAD-170
>                 URL: https://issues.apache.org/jira/browse/FILEUPLOAD-170
>             Project: Commons FileUpload
>          Issue Type: Bug
>         Environment: OS: fedora7
> IDE:Netbeans
>            Reporter: vaishali dolas
>
> I'm facing problem to build progressbar while file uploading
> the code snippet is here
> // Create a factory for disk-based file items
> FileItemFactory factory = new DiskFileItemFactory();
> // Create a new file upload handler
> ServletFileUpload upload = new ServletFileUpload(factory);
> // Parse the request
> List   items = upload.parseRequest(request);
> In items i'm always getting null

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Resolved: (FILEUPLOAD-170) problem in parseRequest method of

Posted by "Jochen Wiedmann (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/FILEUPLOAD-170?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Jochen Wiedmann resolved FILEUPLOAD-170.
----------------------------------------

    Resolution: Invalid
      Assignee: Jochen Wiedmann

As discussed in the previous comment.


> problem in parseRequest method of 
> ----------------------------------
>
>                 Key: FILEUPLOAD-170
>                 URL: https://issues.apache.org/jira/browse/FILEUPLOAD-170
>             Project: Commons FileUpload
>          Issue Type: Bug
>         Environment: OS: fedora7
> IDE:Netbeans
>            Reporter: vaishali dolas
>            Assignee: Jochen Wiedmann
>
> I'm facing problem to build progressbar while file uploading
> the code snippet is here
> // Create a factory for disk-based file items
> FileItemFactory factory = new DiskFileItemFactory();
> // Create a new file upload handler
> ServletFileUpload upload = new ServletFileUpload(factory);
> // Parse the request
> List   items = upload.parseRequest(request);
> In items i'm always getting null

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (FILEUPLOAD-170) problem in parseRequest method of

Posted by "vaishali dolas (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/FILEUPLOAD-170?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12656561#action_12656561 ] 

vaishali dolas commented on FILEUPLOAD-170:
-------------------------------------------

I'm using commons-fileupload 1.2.1 version
Some one told me that This most commonly happens when the request has already been parsed, or processed in some other way. Since the input stream has aleady been consumed by that earlier process, it is no longer available for parsing by Commons FileUpload.

Am i required to write my own MultiPartRequest handler to get solution.But i'm very new to this struts2.
Can you tell me is it will solve my problem.& if so then how to implement that class?

> problem in parseRequest method of 
> ----------------------------------
>
>                 Key: FILEUPLOAD-170
>                 URL: https://issues.apache.org/jira/browse/FILEUPLOAD-170
>             Project: Commons FileUpload
>          Issue Type: Bug
>         Environment: OS: fedora7
> IDE:Netbeans
>            Reporter: vaishali dolas
>
> I'm facing problem to build progressbar while file uploading
> the code snippet is here
> // Create a factory for disk-based file items
> FileItemFactory factory = new DiskFileItemFactory();
> // Create a new file upload handler
> ServletFileUpload upload = new ServletFileUpload(factory);
> // Parse the request
> List   items = upload.parseRequest(request);
> In items i'm always getting null

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (FILEUPLOAD-170) problem in parseRequest method of

Posted by "Jochen Wiedmann (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/FILEUPLOAD-170?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12656563#action_12656563 ] 

Jochen Wiedmann commented on FILEUPLOAD-170:
--------------------------------------------

I'll show you the code. (See below.) Assuming that there is no bug in the JVM (for which commons-fileupload cannot take responsibility), note that:

- The variable "items" is initialized at the beginning. It is never changed.
  It can never be null.
- There is only one "return" statement, which returns "items". Hence it
  is impossible that null is returned.
- The elements added to "items" are stored in the variable "fileItem".
- These elements can also never be null: Otherwise, you'd get a NullPointerException
  when Streams.copy is invoked.

Please contact the Struts users mailing list for help. This is a bug tracker, not a support forum.




    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;
        } catch (FileUploadIOException e) {
            throw (FileUploadException) e.getCause();
        } catch (IOException e) {
            throw new FileUploadException(e.getMessage(), e);
        }
    }


> problem in parseRequest method of 
> ----------------------------------
>
>                 Key: FILEUPLOAD-170
>                 URL: https://issues.apache.org/jira/browse/FILEUPLOAD-170
>             Project: Commons FileUpload
>          Issue Type: Bug
>         Environment: OS: fedora7
> IDE:Netbeans
>            Reporter: vaishali dolas
>
> I'm facing problem to build progressbar while file uploading
> the code snippet is here
> // Create a factory for disk-based file items
> FileItemFactory factory = new DiskFileItemFactory();
> // Create a new file upload handler
> ServletFileUpload upload = new ServletFileUpload(factory);
> // Parse the request
> List   items = upload.parseRequest(request);
> In items i'm always getting null

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.