This is an automated email from the ASF dual-hosted git repository.
ggregory pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/commons-fileupload.git
The following commit(s) were added to refs/heads/master by this push:
new bd84fd3b [FILEUPLOAD-355] Update code example: Use IOUtils instead of
Streams utils class
bd84fd3b is described below
commit bd84fd3ba87912b120c046969917f8ba850de215
Author: Gary Gregory <[email protected]>
AuthorDate: Thu May 9 08:57:20 2024 -0400
[FILEUPLOAD-355] Update code example: Use IOUtils instead of Streams
utils class
---
src/changes/changes.xml | 1 +
src/site/xdoc/streaming.xml | 5 ++++-
2 files changed, 5 insertions(+), 1 deletion(-)
diff --git a/src/changes/changes.xml b/src/changes/changes.xml
index 4af40bbb..0549af2f 100644
--- a/src/changes/changes.xml
+++ b/src/changes/changes.xml
@@ -46,6 +46,7 @@ The <action> type attribute can be add,update,fix,remove.
<release version="2.0.0" date="2024-MM-DD" description="2.0.0 Release,
requires Java 11.">
<!-- FIX -->
<action dev="ggregory" type="fix" due-to="Gregor
Dschung">[site] Fix instantiation of DiskFileItemFactory in migration guide
#273.</action>
+ <action issue="FILEUPLOAD-355" dev="ggregory" type="fix" due-to="Ana,
Gary Gregory">[site] Update code example: Use IOUtils instead of Streams utils
class.</action>
<!-- ADD -->
<!-- UDPATE -->
<action dev="ggregory" type="update" due-to="Gary
Gregory">Bump org.apache.commons:commons-parent from 66 to 69 #283,
#294.</action>
diff --git a/src/site/xdoc/streaming.xml b/src/site/xdoc/streaming.xml
index ba8ac5d1..650475f9 100644
--- a/src/site/xdoc/streaming.xml
+++ b/src/site/xdoc/streaming.xml
@@ -61,6 +61,9 @@ boolean isMultipart =
JakartaServletFileUpload.isMultipartContent(request);]]></
how we do it:
</p>
<source><![CDATA[// Create a new file upload handler
+import java.nio.charset.Charset;
+import org.apache.commons.io.IOUtils;
+
JakartaServletFileUpload upload = new JakartaServletFileUpload();
// Parse the request
@@ -69,7 +72,7 @@ upload.getItemIterator(request).forEachRemaining(item -> {
InputStream stream = item.getInputStream();
if (item.isFormField()) {
System.out.println("Form field " + name + " with value "
- + Streams.asString(stream) + " detected.");
+ + IOUtils.toString(stream, Charset.defaultCharset()) + "
detected.");
} else {
System.out.println("File field " + name + " with file name "
+ item.getName() + " detected.");