Multiple File Uploads

classic Classic list List threaded Threaded
7 messages Options
Reply | Threaded
Open this post in threaded view
|

Multiple File Uploads

Asleson, Ryan-2
Hello,

How can I use Stripes file uploads with the HTML multiple input tag?  

For example, if I use this HTML tag to allow multiple files to be selected for upload:

<input type=“file” name=“files[]” multiple>

How do I handle the multiple files in Stripes?

The “name” attribute I’m using above, with the brackets, is how I’ve seen it on other examples on the web.  I know Stripes uses brackets for indexed properties, but in this case I can’t fill in an index number within the brackets.

I did try an example similar to the above, with this in the ActionBean class:

private List<FileBean> files;

With a public getter and setter, but Stripes didn’t appear to populate it.

Thank you!!!


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
[hidden email]
https://lists.sourceforge.net/lists/listinfo/stripes-users
Reply | Threaded
Open this post in threaded view
|

Re: Multiple File Uploads

Rick Grashel

Hi Ryan,

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

-- Rick

On Jan 22, 2016 10:32 AM, "Asleson, Ryan" <[hidden email]> wrote:
Hello,

How can I use Stripes file uploads with the HTML multiple input tag?  

For example, if I use this HTML tag to allow multiple files to be selected for upload:

<input type=“file” name=“files[]” multiple>

How do I handle the multiple files in Stripes?

The “name” attribute I’m using above, with the brackets, is how I’ve seen it on other examples on the web.  I know Stripes uses brackets for indexed properties, but in this case I can’t fill in an index number within the brackets.

I did try an example similar to the above, with this in the ActionBean class:

private List<FileBean> files;

With a public getter and setter, but Stripes didn’t appear to populate it.

Thank you!!!


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
[hidden email]
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
[hidden email]
https://lists.sourceforge.net/lists/listinfo/stripes-users
Reply | Threaded
Open this post in threaded view
|

Re: Multiple File Uploads

Mike McNally-3
I was going to look up the Stripes tag fie doc to see if the Stripes <input> tag could accept the "multiple" attribute, but I can't because the Stripes wiki link to the Tag doc is currently broken :/

On Fri, Jan 22, 2016 at 4:57 PM Rick Grashel <[hidden email]> wrote:

Hi Ryan,

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

-- Rick

On Jan 22, 2016 10:32 AM, "Asleson, Ryan" <[hidden email]> wrote:
Hello,

How can I use Stripes file uploads with the HTML multiple input tag?  

For example, if I use this HTML tag to allow multiple files to be selected for upload:

<input type=“file” name=“files[]” multiple>

How do I handle the multiple files in Stripes?

The “name” attribute I’m using above, with the brackets, is how I’ve seen it on other examples on the web.  I know Stripes uses brackets for indexed properties, but in this case I can’t fill in an index number within the brackets.

I did try an example similar to the above, with this in the ActionBean class:

private List<FileBean> files;

With a public getter and setter, but Stripes didn’t appear to populate it.

Thank you!!!


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
[hidden email]
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
[hidden email]
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
[hidden email]
https://lists.sourceforge.net/lists/listinfo/stripes-users
Reply | Threaded
Open this post in threaded view
|

Re: Multiple File Uploads

Mike McNally-3
Anyway I don't think that Stripes <input> tags support the "multiple" attribute so it's not possible to use the Stripes tags anyway. Multiple file uploads have been possible for years with modern browsers. I think I had to write a special property binder to deal with that in my application that allowed multiple files.

On Fri, Jan 22, 2016 at 6:24 PM Mike McNally <[hidden email]> wrote:
I was going to look up the Stripes tag fie doc to see if the Stripes <input> tag could accept the "multiple" attribute, but I can't because the Stripes wiki link to the Tag doc is currently broken :/

On Fri, Jan 22, 2016 at 4:57 PM Rick Grashel <[hidden email]> wrote:

Hi Ryan,

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

-- Rick

On Jan 22, 2016 10:32 AM, "Asleson, Ryan" <[hidden email]> wrote:
Hello,

How can I use Stripes file uploads with the HTML multiple input tag?  

For example, if I use this HTML tag to allow multiple files to be selected for upload:

<input type=“file” name=“files[]” multiple>

How do I handle the multiple files in Stripes?

The “name” attribute I’m using above, with the brackets, is how I’ve seen it on other examples on the web.  I know Stripes uses brackets for indexed properties, but in this case I can’t fill in an index number within the brackets.

I did try an example similar to the above, with this in the ActionBean class:

private List<FileBean> files;

With a public getter and setter, but Stripes didn’t appear to populate it.

Thank you!!!


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
[hidden email]
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
[hidden email]
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
[hidden email]
https://lists.sourceforge.net/lists/listinfo/stripes-users
Reply | Threaded
Open this post in threaded view
|

Re: Multiple File Uploads

Asleson, Ryan-2
In reply to this post by Rick Grashel

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 <[hidden email]>
Reply-To: Stripes Users List <[hidden email]>
Date: Friday, January 22, 2016 at 4:56 PM
To: Stripes Users List <[hidden email]>
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
[hidden email]
https://lists.sourceforge.net/lists/listinfo/stripes-users
Reply | Threaded
Open this post in threaded view
|

Re: Multiple File Uploads

Rick Grashel
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 <[hidden email]> 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 <[hidden email]>
Reply-To: Stripes Users List <[hidden email]>
Date: Friday, January 22, 2016 at 4:56 PM
To: Stripes Users List <[hidden email]>
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
[hidden email]
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
[hidden email]
https://lists.sourceforge.net/lists/listinfo/stripes-users
Reply | Threaded
Open this post in threaded view
|

Re: Multiple File Uploads

Poitras Christian
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 <[hidden email]<mailto:[hidden email]>>
Répondre à : Stripes Users List <[hidden email]<mailto:[hidden email]>>
Date : Monday, January 25, 2016 at 8:38 AM
À : Stripes Users List <[hidden email]<mailto:[hidden email]>>
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 <[hidden email]<mailto:[hidden email]>> 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 <[hidden email]<mailto:[hidden email]>>
Reply-To: Stripes Users List <[hidden email]<mailto:[hidden email]>>
Date: Friday, January 22, 2016 at 4:56 PM
To: Stripes Users List <[hidden email]<mailto:[hidden email]>>
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
[hidden email]<mailto:[hidden email]>
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
[hidden email]
https://lists.sourceforge.net/lists/listinfo/stripes-users