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

Gary D. Gregory edited comment on FILEUPLOAD-355 at 5/9/24 12:57 PM:
---------------------------------------------------------------------

This functionality does not belong in FileUpload, please use Apache Commons IO: 
{code:java}
org.apache.commons.io.IOUtils.toString(InputStream, String)
{code}
or:
{code:java}
org.apache.commons.io.IOUtils.toString(InputStream, Charset)
{code}
I've updated the site in git master.



was (Author: garydgregory):
This functionality does not belong in FileUpload, please use Apache Commons IO: 
{code:java}
org.apache.commons.io.IOUtils.toString(InputStream, String)
{code}
or:
{code:java}
org.apache.commons.io.IOUtils.toString(InputStream, Charset)
{code}
I'll update the docs.


> Update code example: Use IOUtils instead of Streams utils class
> ---------------------------------------------------------------
>
>                 Key: FILEUPLOAD-355
>                 URL: https://issues.apache.org/jira/browse/FILEUPLOAD-355
>             Project: Commons FileUpload
>          Issue Type: Wish
>    Affects Versions: 2.0.0-M2
>            Reporter: Ana
>            Priority: Major
>             Fix For: 2.0.0
>
>
> I'm trying to use the Streaming API in *commons-fileupload2-jakarta-serverl6 
> v 2.0.0-M2*  like [in this 
> example|https://commons.apache.org/proper/commons-fileupload/streaming.html]:]:
> {code:java}
> // Create a new file upload handler
> JakartaServletFileUpload upload = new JakartaServletFileUpload();
> // Parse the request
> upload.getItemIterator(request).forEachRemaining(item -> {
>     String name = item.getFieldName();
>     InputStream stream = item.getInputStream();
>     if (item.isFormField()) {
>         System.out.println("Form field " + name + " with value "
>             + Streams.asString(stream) + " detected.");
>     } else {
>         System.out.println("File field " + name + " with file name "
>             + item.getName() + " detected.");
>         // Process the input stream
>         ...
>     }
> }); {code}
> But the org.apache.commons.fileupload.util.Streams class cannot be found. It 
> doesn't seem to have been ported to v2. Are there any plans to add it to 
> future releases?
>  



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

Reply via email to