Hi,

It is possible, but it’s not easy. As least not in version 1.5.x.
I programmed a utility class that renames multiple fileBeans[0] into 
fileBeans[0..X] so it woks with Stripes, but I never really used it in 
production.

You will probably obtain better results with a javascript library for this like 
https://blueimp.github.io/jQuery-File-Upload/basic.html


If you really want to try my code, here is the gist of it.

Subclass net.sourceforge.stripes.controller.multipart.CommonsMultipartWrapper.

Copy and override  public void build(HttpServletRequest request, File tempDir, 
long maxPostSize) throws IOException,

FileUploadLimitExceededException {

At some point:

for (FileItem item : items) {

// If it's a form field, add the string value to the list

if (item.isFormField()) {

List<String> values = params.get(item.getFieldName());

if (values == null) {

values = new ArrayList<String>();

params.put(item.getFieldName(), values);

}

values.add(charset == null ? item.getString() : item.getString(charset));

}

// Else store the file param

// Part that changes

else {

processFile(item, files);

}

// End of changes

}


private void processFile(FileItem item, Map<String, FileItem> files) {

if (item.getFieldName().endsWith("[0]") && 
files.containsKey(item.getFieldName())) {

String baseName = item.getFieldName().substring(0, item.getFieldName().length() 
- 3);

int index = 0;

while (files.containsKey(baseName + "[" + index + "]")) {

index++;

}

log.trace("renaming file parameter " + item.getFieldName() + " to " + baseName 
+ "[" + index + "]");

files.put(baseName + "[" + index + "]", item);

} else {

files.put(item.getFieldName(), item);

}

}



De : Rick Grashel <rgras...@gmail.com<mailto:rgras...@gmail.com>>
Répondre à : Stripes Users List 
<stripes-users@lists.sourceforge.net<mailto:stripes-users@lists.sourceforge.net>>
Date : Monday, January 25, 2016 at 8:38 AM
À : Stripes Users List 
<stripes-users@lists.sourceforge.net<mailto:stripes-users@lists.sourceforge.net>>
Objet : Re: [Stripes-users] Multiple File Uploads

I've done enumerations of FileBean uploads, but not using "fileBeans[]" as the 
name for all of the file inputs.  I have to admit that I don't remember ever 
trying that.  Instead, I have specified the actual actionBean index.  Like this:

<s:file name="fileBeans[0]"/>
<s:file name="fileBeans[1]"/>
<s:file name="fileBeans[2]"/>

It might be possible that file inputs behave differently because they are not 
parsed from the request like normal parameters.  But I'm not 100% sure about 
that.

-- Rick


On Mon, Jan 25, 2016 at 6:19 AM, Asleson, Ryan 
<ryan.asle...@biworldwide.com<mailto:ryan.asle...@biworldwide.com>> wrote:

I don’t use the Stripes JSP tags, at least not usually.  Yes, the example I 
gave is vanilla HTML.

This isn’t a tag issue, though.  I’m wondering if Stripes can handle multiple 
file uploads from the browser when the “multiple” attribute is set on the file 
input tag.  As I said earlier, I know Stripes supports the indexed properties, 
but I don’t know if that can work with how the file input with “multiple” 
submits the files.


From: Rick Grashel <rgras...@gmail.com<mailto:rgras...@gmail.com>>
Reply-To: Stripes Users List 
<stripes-users@lists.sourceforge.net<mailto:stripes-users@lists.sourceforge.net>>
Date: Friday, January 22, 2016 at 4:56 PM
To: Stripes Users List 
<stripes-users@lists.sourceforge.net<mailto:stripes-users@lists.sourceforge.net>>
Subject: Re: [Stripes-users] Multiple File Uploads


Hi Ryan,

Are you using Stripes JSP tags? Your HTML code looks like regular tags.

-- Rick


This e-mail message is being sent solely for use by the intended recipient(s) 
and may contain confidential information. Any unauthorized review, use, 
disclosure or distribution is prohibited. If you are not the intended 
recipient, please contact the sender by phone or reply by e-mail, delete the 
original message and destroy all copies. Thank you.

------------------------------------------------------------------------------
Site24x7 APM Insight: Get Deep Visibility into Application Performance
APM + Mobile APM + RUM: Monitor 3 App instances at just $35/Month
Monitor end-to-end web transactions and take corrective actions now
Troubleshoot faster and improve end-user experience. Signup Now!
http://pubads.g.doubleclick.net/gampad/clk?id=267308311&iu=/4140
_______________________________________________
Stripes-users mailing list
Stripes-users@lists.sourceforge.net<mailto:Stripes-users@lists.sourceforge.net>
https://lists.sourceforge.net/lists/listinfo/stripes-users



------------------------------------------------------------------------------
Site24x7 APM Insight: Get Deep Visibility into Application Performance
APM + Mobile APM + RUM: Monitor 3 App instances at just $35/Month
Monitor end-to-end web transactions and take corrective actions now
Troubleshoot faster and improve end-user experience. Signup Now!
http://pubads.g.doubleclick.net/gampad/clk?id=267308311&iu=/4140
_______________________________________________
Stripes-users mailing list
Stripes-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/stripes-users

Reply via email to