1. I have a form with multipart/form-data which posts to a servlet.
2. The servlet processes the request and forwards to a page.
I have written a custom servlet that extends a SlingAllMethodsServlet.
In the servlet I am checking wether it is a multi part
try
{
if(ServletFileUpload.isMultipartContent(request))
{
List<File> attachedFiles = new ArrayList<File>();
Map<String, RequestParameter[]> params = request.getRequestParameterMap();
Map<String, String[]> parameterMap = null;
for ( Map.Entry<String, RequestParameter[]> pairs : params.entrySet())
{
String key = pairs.getKey();
if(key.equals("fileName1") || key.equals("fileName2") || key.equals("fileName3"))
{
RequestParameter[] paramArray = pairs.getValue();
if(paramArray != null && paramArray.length > 0)
{
RequestParameter param = paramArray[0];
InputStream inputStream = param.getInputStream();
if(inputStream.available() != 0)
{
final File tempFile = File.createTempFile(PREFIX, SUFFIX);
tempFile.deleteOnExit();
try (FileOutputStream outputStream = new FileOutputStream(tempFile))
{
IOUtils.copy(inputStream, outputStream);
}
attachedFiles.add(tempFile);
forwardToThankYouPage(request, response, thankYouPagePath);
}
}
}
}
for some reason the forwardToThankYouPage does not work when the file size is larger than 1 mb. For files of 100bytes the process run's just fine.
Can some one help me figure out.
Thanks,
depath
Solved! Go to Solution.
Views
Replies
Total Likes
Hello depath,
Can you attach the error.log file for the use case when the file size is larger than 1 mb ?
[EDIT] Let me suggest you an alternate approach for your usecase,
Let me know your thoughts.
Thanks
Views
Replies
Total Likes
Hi depath,
Make use of copyLarge method of IOUtil instead of copy.
Thanks,
Sham
Twitter: @adobe_sham
Views
Replies
Total Likes
Hello depath,
Can you attach the error.log file for the use case when the file size is larger than 1 mb ?
[EDIT] Let me suggest you an alternate approach for your usecase,
Let me know your thoughts.
Thanks
Views
Replies
Total Likes