struts-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Greg Huber <gregh3...@gmail.com>
Subject Re: [jira] [Updated] (WW-4717) Refactor file upload support to allow create virtual representation of java.io.File
Date Thu, 24 Nov 2016 14:29:40 GMT
....For every file it calls the UploadedFileConverter, this is the same for
the ajax uploader and a form with multiple upload files.

On 24 November 2016 at 14:08, Lukasz Lenart <lukaszlenart@apache.org> wrote:

> That shouldn't matter but I think how can I test this behaviour.
>
> 2016-11-24 15:03 GMT+01:00 Greg Huber <gregh3269@gmail.com>:
> > Sorry, forgot to add this is not on the app engine!  Was only testing the
> > plugin functionality ie the filter and the listener.  I assume the array
> > comes from when running the webapp on the app engine?
> >
> >
> >
> > On 24 November 2016 at 13:26, Lukasz Lenart <lukaszlenart@apache.org>
> wrote:
> >
> >> Hm... this can be an internal conversion of collection containing
> >> uploaded files. Does your ajax upload allow upload multiple files at
> >> once?
> >>
> >> 2016-11-24 14:18 GMT+01:00 Lukasz Lenart <lukaszlenart@apache.org>:
> >> > How is that possible? I meant, parameters should always be passed as
> >> > arrays, that's how HttpServletRequest works. Do you use custom
> >> > implementation of MultiPartRequest? Could you share your upload logic,
> >> > action and JSP/JavaScript?
> >> >
> >> > That's why JakartaMultiPartRequest (and other implementations as well)
> >> > always creates an array, even if only one file is uploaded:
> >> > https://github.com/lukaszlenart/struts/blob/WW-
> >> 4717/core/src/main/java/org/apache/struts2/dispatcher/multipart/
> >> JakartaMultiPartRequest.java#L110-L118
> >> >
> >> >
> >> > Regards
> >> > --
> >> > Łukasz
> >> > + 48 606 323 122 http://www.lenart.org.pl/
> >> >
> >> > 2016-11-24 12:13 GMT+01:00 Greg Huber <gregh3269@gmail.com>:
> >> >> Seems to be this line in UploadedFileConverter:
> >> >>
> >> >> if (value.getClass().isArray() && Array.getLength(value) ==
1) {
> >> >>
> >> >> where value ==
> >> >> org.apache.struts2.dispatcher.multipart.StrutsUploadedFile@62e25d8
> >> >>
> >> >> and is not an array.
> >> >>
> >> >> this works:
> >> >>
> >> >> Object obj = null;
> >> >>             if (value.getClass().isArray() && Array.getLength(value)
> ==
> >> 1) {
> >> >>                 obj = Array.get(value, 0);
> >> >>             } else {
> >> >>                 obj = value;
> >> >>             }
> >> >>             if (obj instanceof UploadedFile) {
> >> >>                 UploadedFile file = (UploadedFile) obj;
> >> >>                 if (file.getContent() instanceof File) {
> >> >>                     return file.getContent();
> >> >>                 }
> >> >>                 return new File(file.getAbsolutePath());
> >> >>             }
> >> >>
> >> >> This works for both my ajax and normal upload.
> >> >>
> >> >> On 23 November 2016 at 12:56, Lukasz Lenart <lukaszlenart@apache.org
> >
> >> wrote:
> >> >>
> >> >>> Could someone tag that PR with :+1:?
> >> >>>
> >> >>> 2016-11-22 20:41 GMT+01:00 Lukasz Lenart <lukaszlenart@apache.org>:
> >> >>> > All is good :) I have refactored the file upload logic a bit,
> cleaned
> >> >>> > up and fixed some issues with wrong message keys. Also I added
> >> >>> > dedicated converter to keep support for java.io.File so there
is
> no
> >> >>> > need for migration :)
> >> >>> >
> >> >>> > I've also developed a small GAE plugin which is using the
> mentioned
> >> >>> > changes (that's why build cannot pass as a Struts SNAPSHOT
is
> wrong
> >> >>> > ;-)), tested it locally and everything works as expected :D
> >> >>> > https://github.com/lukaszlenart/struts2-gea-plugin
> >> >>> >
> >> >>> > Can you take a look on that PR?
> >> >>> >
> >> >>> >
> >> >>> > Thanks in advance
> >> >>> > --
> >> >>> > Łukasz
> >> >>> > + 48 606 323 122 http://www.lenart.org.pl/
> >> >>> >
> >> >>> > 2016-11-22 9:44 GMT+01:00 Lukasz Lenart <lukaszlenart@apache.org
> >:
> >> >>> >> Done, thanks Aaron :) Now I must test this solution with
Google
> >> >>> AppEngine ;-)
> >> >>> >>
> >> >>> >> 2016-11-22 7:49 GMT+01:00 Lukasz Lenart <lukaszlenart@apache.org
> >:
> >> >>> >>> 2016-11-21 20:12 GMT+01:00 Aaron Johnson <
> johnson.aaron5@gmail.com
> >> >:
> >> >>> >>>> Is it possible to have a converter from UploadedFile
to File?
> The
> >> >>> >>>> UploadedFile has a getContent() method that returns
the File
> >> object.
> >> >>> >>>
> >> >>> >>> Hm... it would be possible to add a converter, that
should work
> :)
> >> >>> >>>
> >> >>> >>>
> >> >>> >>> Regards
> >> >>> >>> --
> >> >>> >>> Łukasz
> >> >>> >>> + 48 606 323 122 http://www.lenart.org.pl/
> >> >>>
> >> >>> ------------------------------------------------------------
> ---------
> >> >>> To unsubscribe, e-mail: dev-unsubscribe@struts.apache.org
> >> >>> For additional commands, e-mail: dev-help@struts.apache.org
> >> >>>
> >> >>>
> >>
> >> ---------------------------------------------------------------------
> >> To unsubscribe, e-mail: dev-unsubscribe@struts.apache.org
> >> For additional commands, e-mail: dev-help@struts.apache.org
> >>
> >>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe@struts.apache.org
> For additional commands, e-mail: dev-help@struts.apache.org
>
>

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message