On Sun, 8 Oct 2023 at 23:17, Gary Gregory <garydgreg...@gmail.com> wrote: > > Please provide a PR so tye build checks can run.
Done: https://github.com/apache/commons-fileupload/pull/248 sorry for delay > > TY, > Gary > > On Sun, Oct 8, 2023, 11:52 AM Maxim Solodovnik <solomax...@gmail.com> wrote: > > > Here is the patch inlined (not sure if it worth PR ... ) > > > > ======================================================================== > > diff --git > > a/commons-fileupload2-jakarta-servlet5/src/test/java/org/apache/commons/fileupload2/jakarta/servlet5/JakartaServletFileUploadTest.java > > > > b/commons-fileupload2-jakarta-servlet5/src/test/java/org/apache/commons/fileupload2/jakarta/servlet5/JakartaServletFileUploadTest.java > > index 06b8de62..b3f1c772 100644 > > --- > > a/commons-fileupload2-jakarta-servlet5/src/test/java/org/apache/commons/fileupload2/jakarta/servlet5/JakartaServletFileUploadTest.java > > +++ > > b/commons-fileupload2-jakarta-servlet5/src/test/java/org/apache/commons/fileupload2/jakarta/servlet5/JakartaServletFileUploadTest.java > > @@ -19,8 +19,10 @@ package org.apache.commons.fileupload2.jakarta.servlet5; > > import static org.junit.jupiter.api.Assertions.assertEquals; > > import static org.junit.jupiter.api.Assertions.assertTrue; > > > > +import java.io.InputStream; > > import java.nio.charset.StandardCharsets; > > import java.util.List; > > +import java.util.concurrent.atomic.AtomicInteger; > > > > import org.apache.commons.fileupload2.core.AbstractFileUploadTest; > > import org.apache.commons.fileupload2.core.Constants; > > @@ -107,6 +109,22 @@ public class JakartaServletFileUploadTest > > > > assertTrue(mappedParameters.containsKey("multi")); > > assertEquals(2, mappedParameters.get("multi").size()); > > + > > + final var itemCount = new AtomicInteger(0); > > + upload.getItemIterator(request).forEachRemaining(item -> { > > + itemCount.incrementAndGet(); > > + String name = item.getFieldName(); > > + InputStream stream = item.getInputStream(); > > + if (item.isFormField()) { > > + System.out.println("Form field " + name + " with value " > > + + " detected."); > > + } else { > > + System.out.println("File field " + name + " with file > > name " > > + + item.getName() + " detected."); > > + // Process the input stream > > + } > > + }); > > + assertEquals(4, itemCount.get()); > > } > > > > @Override > > > > On Fri, 29 Sept 2023 at 19:00, Gary Gregory <garydgreg...@gmail.com> > > wrote: > > > > > > Please provide a patch attached to a Jira ticket or a PR for a failing > > unit > > > test to make it simple for a maintainer to help you out. > > > > > > Gary > > > > > > On Thu, Sep 28, 2023, 12:39 AM Maxim Solodovnik <solomax...@gmail.com> > > > wrote: > > > > > > > Hello, > > > > > > > > I've tried to check this one :) > > > > > > > > Modified this test: > > > > > > > > > > commons-fileupload2-jakarta-servlet5/src/test/java/org/apache/commons/fileupload2/jakarta/servlet5/JakartaServletFileUploadTest.java > > > > > > > > Add this block at the bottom: > > > > > > > > ``` > > > > final var itemCount = new AtomicInteger(0); > > > > upload.getItemIterator(new JakartaMockServletHttpRequest(bytes, > > > > Constants.CONTENT_TYPE)).forEachRemaining(item -> { > > > > String name = item.getFieldName(); > > > > InputStream stream = item.getInputStream(); > > > > if (item.isFormField()) { > > > > System.out.println("Form field " + name + " with value " + " > > > > detected."); > > > > } else { > > > > System.out.println("File field " + name + " with file name " + > > > > item.getName() + " detected."); > > > > // Process the input stream > > > > } > > > > }); > > > > assertEquals(4, itemCount.get()); > > > > ``` > > > > > > > > The test is GREEN > > > > > > > > BUT > > > > > > > > if i try to reuse previously created request like this: > > > > > > > > ``` > > > > upload.getItemIterator(request).forEachRemaining(item -> { > > > > ``` > > > > > > > > The test will fail > > > > > > > > > > > > Is it be possible request was already iterated before > > > > `forEachRemaining` was called? > > > > > > > > On Thu, 28 Sept 2023 at 08:31, Gary Gregory <garydgreg...@gmail.com> > > > > wrote: > > > > > > > > > > Hi, > > > > > > > > > > The best way to help would be to provide a PR on GitHub with a > > failing > > > > > test, and if you find it, a fix. > > > > > > > > > > Gary > > > > > > > > > > > > > > > On Wed, Sep 27, 2023, 7:33 PM Ian Evans < > > ian_robert_ev...@hotmail.com> > > > > > wrote: > > > > > > > > > > > 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 > > > > > > } > > > > > > }); > > > > > > ... > > > > > > } > > > > > > > > > > > > If I can help diagnose the issue in any way I'm more than happy. > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > -- > > > > Best regards, > > > > Maxim > > > > > > > > --------------------------------------------------------------------- > > > > To unsubscribe, e-mail: user-unsubscr...@commons.apache.org > > > > For additional commands, e-mail: user-h...@commons.apache.org > > > > > > > > > > > > > > > > -- > > Best regards, > > Maxim > > > > --------------------------------------------------------------------- > > To unsubscribe, e-mail: user-unsubscr...@commons.apache.org > > For additional commands, e-mail: user-h...@commons.apache.org > > > > -- Best regards, Maxim --------------------------------------------------------------------- To unsubscribe, e-mail: user-unsubscr...@commons.apache.org For additional commands, e-mail: user-h...@commons.apache.org