You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@commons.apache.org by "Rob Tompkins (Jira)" <ji...@apache.org> on 2023/10/10 16:08:00 UTC

[jira] [Comment Edited] (FILEUPLOAD-353) JakartaServletFileUpload.getItemIterator() not working in 2.0.0-M1

    [ https://issues.apache.org/jira/browse/FILEUPLOAD-353?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17773725#comment-17773725 ] 

Rob Tompkins edited comment on FILEUPLOAD-353 at 10/10/23 4:07 PM:
-------------------------------------------------------------------

Working on that. This is just something that came in from the user's list. I figure'd that I should log it here, but I'm a little lost with how to get the dev environment going to sort this one out. I suppose I'll write a test that does this and see what happens.


was (Author: chtompki):
Working on that. This is just something that came in from the user's list....any suggestions on how I would go about testing this?

> JakartaServletFileUpload.getItemIterator() not working in 2.0.0-M1
> ------------------------------------------------------------------
>
>                 Key: FILEUPLOAD-353
>                 URL: https://issues.apache.org/jira/browse/FILEUPLOAD-353
>             Project: Commons FileUpload
>          Issue Type: Bug
>            Reporter: Rob Tompkins
>            Assignee: Rob Tompkins
>            Priority: Major
>
> Using the following library:
> <dependency>
>   <groupId>org.apache.commons</groupId>
>   <artifactId>commons-fileupload2-jakarta</artifactId>
>   <version>2.0.0-M1</version>
> </dependency>
> The Streaming API (documented here FileUpload – The Streaming API (apache.org)<https://commons.apache.org/proper/commons-fileupload/streaming.html>)  does not return any items. I've tested the following code using postman and curl to send a multipart/form-data request, in both cases getItemIterator fails to return any items (internally it seems an exceptio is thrown):
> public ResponseEntity<Void> upload(HttpServletRequest request) throws IOException {
>        if (!JakartaServletFileUpload.isMultipartContent(request)) {
>            throw new IllegalArgumentException("not multipart");
>        }
>        JakartaServletFileUpload upload = new JakartaServletFileUpload();
>        upload.getItemIterator(request).forEachRemaining(item -> {
>            String name = item.getFieldName();
>            InputStream stream = item.getInputStream();
>            if (item.isFormField()) {
>                System.out.println("Form field " + name + " with value "
>                        + convertInputStreamToString(stream) + " detected.");
>            } else {
>                System.out.println("File field " + name + " with file name "
>                        + item.getName() + " detected.");
>                // Process the input stream
>            }
>        });
>       ...
> }



--
This message was sent by Atlassian Jira
(v8.20.10#820010)