You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@struts.apache.org by Lukasz Lenart <lu...@apache.org> on 2016/11/21 09:58:11 UTC

Re: [jira] [Updated] (WW-4717) Refactor file upload support to allow create virtual representation of java.io.File

I would like to refactor file upload logic to use a virtual
representation of a file but this requires changes in users'
applications as well, instead of using java.io.File they will have to
switch to UploadedFile Struts class.

Not sure if it is worth doing :\


Regards
-- 
Łukasz
+ 48 606 323 122 http://www.lenart.org.pl/

2016-11-21 10:09 GMT+01:00 Lukasz Lenart (JIRA) <ji...@apache.org>:
>
>      [ https://issues.apache.org/jira/browse/WW-4717?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
>
> Lukasz Lenart updated WW-4717:
> ------------------------------
>     Summary: Refactor file upload support to allow create virtual representation of java.io.File  (was: Refactor file upload support to allow create virtual representation of java.ioFile)
>
>> Refactor file upload support to allow create virtual representation of java.io.File
>> -----------------------------------------------------------------------------------
>>
>>                 Key: WW-4717
>>                 URL: https://issues.apache.org/jira/browse/WW-4717
>>             Project: Struts 2
>>          Issue Type: Improvement
>>          Components: Core
>>    Affects Versions: 2.5.5
>>            Reporter: Lukasz Lenart
>>            Assignee: Lukasz Lenart
>>             Fix For: 2.5.6
>>
>>
>> Right now file upload logic is using {{java.io.File}} directly to represent uploaded files but access to this class is restricted in some cloud environments  e.g. Google AppEngine
>
>
>
> --
> This message was sent by Atlassian JIRA
> (v6.3.4#6332)

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@struts.apache.org
For additional commands, e-mail: dev-help@struts.apache.org


Re: [jira] [Updated] (WW-4717) Refactor file upload support to allow create virtual representation of java.io.File

Posted by Lukasz Lenart <lu...@apache.org>.
PR is here https://github.com/apache/struts/pull/114

2016-11-21 10:58 GMT+01:00 Lukasz Lenart <lu...@apache.org>:
> I would like to refactor file upload logic to use a virtual
> representation of a file but this requires changes in users'
> applications as well, instead of using java.io.File they will have to
> switch to UploadedFile Struts class.
>
> Not sure if it is worth doing :\
>
>
> Regards
> --
> Łukasz
> + 48 606 323 122 http://www.lenart.org.pl/
>
> 2016-11-21 10:09 GMT+01:00 Lukasz Lenart (JIRA) <ji...@apache.org>:
>>
>>      [ https://issues.apache.org/jira/browse/WW-4717?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
>>
>> Lukasz Lenart updated WW-4717:
>> ------------------------------
>>     Summary: Refactor file upload support to allow create virtual representation of java.io.File  (was: Refactor file upload support to allow create virtual representation of java.ioFile)
>>
>>> Refactor file upload support to allow create virtual representation of java.io.File
>>> -----------------------------------------------------------------------------------
>>>
>>>                 Key: WW-4717
>>>                 URL: https://issues.apache.org/jira/browse/WW-4717
>>>             Project: Struts 2
>>>          Issue Type: Improvement
>>>          Components: Core
>>>    Affects Versions: 2.5.5
>>>            Reporter: Lukasz Lenart
>>>            Assignee: Lukasz Lenart
>>>             Fix For: 2.5.6
>>>
>>>
>>> Right now file upload logic is using {{java.io.File}} directly to represent uploaded files but access to this class is restricted in some cloud environments  e.g. Google AppEngine
>>
>>
>>
>> --
>> This message was sent by Atlassian JIRA
>> (v6.3.4#6332)

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@struts.apache.org
For additional commands, e-mail: dev-help@struts.apache.org


Re: [jira] [Updated] (WW-4717) Refactor file upload support to allow create virtual representation of java.io.File

Posted by Lukasz Lenart <lu...@apache.org>.
Greg
Pushed changes based on your suggestions and added a unit test to
cover the logic, thanks :)


Regards
-- 
Łukasz
+ 48 606 323 122 http://www.lenart.org.pl/

2016-11-24 14:26 GMT+01:00 Lukasz Lenart <lu...@apache.org>:
> 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 <lu...@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 <gr...@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 <lu...@apache.org> wrote:
>>>
>>>> Could someone tag that PR with :+1:?
>>>>
>>>> 2016-11-22 20:41 GMT+01:00 Lukasz Lenart <lu...@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 <lu...@apache.org>:
>>>> >> Done, thanks Aaron :) Now I must test this solution with Google
>>>> AppEngine ;-)
>>>> >>
>>>> >> 2016-11-22 7:49 GMT+01:00 Lukasz Lenart <lu...@apache.org>:
>>>> >>> 2016-11-21 20:12 GMT+01:00 Aaron Johnson <jo...@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


Re: [jira] [Updated] (WW-4717) Refactor file upload support to allow create virtual representation of java.io.File

Posted by Lukasz Lenart <lu...@apache.org>.
Cool, I think we are good to go with this refactoring, the rest can be
resolved during a test build period.

Thanks a lot Greg for your help :)


Regards
-- 
Łukasz
+ 48 606 323 122 http://www.lenart.org.pl/


2016-11-24 15:29 GMT+01:00 Greg Huber <gr...@gmail.com>:
> ....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 <lu...@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 <gr...@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 <lu...@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 <lu...@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 <gr...@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 <lu...@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
>>
>>

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@struts.apache.org
For additional commands, e-mail: dev-help@struts.apache.org


Re: [jira] [Updated] (WW-4717) Refactor file upload support to allow create virtual representation of java.io.File

Posted by Greg Huber <gr...@gmail.com>.
....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 <lu...@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 <gr...@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 <lu...@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 <lu...@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 <gr...@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 <lu...@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
>
>

Re: [jira] [Updated] (WW-4717) Refactor file upload support to allow create virtual representation of java.io.File

Posted by Lukasz Lenart <lu...@apache.org>.
That shouldn't matter but I think how can I test this behaviour.

2016-11-24 15:03 GMT+01:00 Greg Huber <gr...@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 <lu...@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 <lu...@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 <gr...@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 <lu...@apache.org>
>> wrote:
>> >>
>> >>> Could someone tag that PR with :+1:?
>> >>>
>> >>> 2016-11-22 20:41 GMT+01:00 Lukasz Lenart <lu...@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 <lu...@apache.org>:
>> >>> >> Done, thanks Aaron :) Now I must test this solution with Google
>> >>> AppEngine ;-)
>> >>> >>
>> >>> >> 2016-11-22 7:49 GMT+01:00 Lukasz Lenart <lu...@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


Re: [jira] [Updated] (WW-4717) Refactor file upload support to allow create virtual representation of java.io.File

Posted by Greg Huber <gr...@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 <lu...@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 <lu...@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 <gr...@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 <lu...@apache.org>
> wrote:
> >>
> >>> Could someone tag that PR with :+1:?
> >>>
> >>> 2016-11-22 20:41 GMT+01:00 Lukasz Lenart <lu...@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 <lu...@apache.org>:
> >>> >> Done, thanks Aaron :) Now I must test this solution with Google
> >>> AppEngine ;-)
> >>> >>
> >>> >> 2016-11-22 7:49 GMT+01:00 Lukasz Lenart <lu...@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
>
>

Re: [jira] [Updated] (WW-4717) Refactor file upload support to allow create virtual representation of java.io.File

Posted by Lukasz Lenart <lu...@apache.org>.
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 <lu...@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 <gr...@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 <lu...@apache.org> wrote:
>>
>>> Could someone tag that PR with :+1:?
>>>
>>> 2016-11-22 20:41 GMT+01:00 Lukasz Lenart <lu...@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 <lu...@apache.org>:
>>> >> Done, thanks Aaron :) Now I must test this solution with Google
>>> AppEngine ;-)
>>> >>
>>> >> 2016-11-22 7:49 GMT+01:00 Lukasz Lenart <lu...@apache.org>:
>>> >>> 2016-11-21 20:12 GMT+01:00 Aaron Johnson <jo...@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


Re: [jira] [Updated] (WW-4717) Refactor file upload support to allow create virtual representation of java.io.File

Posted by Lukasz Lenart <lu...@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 <gr...@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 <lu...@apache.org> wrote:
>
>> Could someone tag that PR with :+1:?
>>
>> 2016-11-22 20:41 GMT+01:00 Lukasz Lenart <lu...@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 <lu...@apache.org>:
>> >> Done, thanks Aaron :) Now I must test this solution with Google
>> AppEngine ;-)
>> >>
>> >> 2016-11-22 7:49 GMT+01:00 Lukasz Lenart <lu...@apache.org>:
>> >>> 2016-11-21 20:12 GMT+01:00 Aaron Johnson <jo...@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


Re: [jira] [Updated] (WW-4717) Refactor file upload support to allow create virtual representation of java.io.File

Posted by Greg Huber <gr...@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 <lu...@apache.org> wrote:

> Could someone tag that PR with :+1:?
>
> 2016-11-22 20:41 GMT+01:00 Lukasz Lenart <lu...@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 <lu...@apache.org>:
> >> Done, thanks Aaron :) Now I must test this solution with Google
> AppEngine ;-)
> >>
> >> 2016-11-22 7:49 GMT+01:00 Lukasz Lenart <lu...@apache.org>:
> >>> 2016-11-21 20:12 GMT+01:00 Aaron Johnson <jo...@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
>
>

Re: [jira] [Updated] (WW-4717) Refactor file upload support to allow create virtual representation of java.io.File

Posted by Greg Huber <gr...@gmail.com>.
....found it here :

https://github.com/lukaszlenart/struts/tree/WW-4717

Followed the instructions for the filter and listener updates to web.xml
and I get:


2016-11-24 10:01:03,825 WARN
org.apache.struts2.conversion.UploadedFileConverter
UploadedFileConverter:convertValue - Converting java.io.File into
org.apache.struts2.dispatcher.multipart.UploadedFile, consider switching to
org.apache.struts2.dispatcher.multipart.UploadedFile and do not access
java.io.File directly!
2016-11-24 10:01:03,949 ERROR mypackage.Resources Resources:upload - ERROR:
uploading resource
java.lang.NullPointerException: null




On 23 November 2016 at 12:56, Lukasz Lenart <lu...@apache.org> wrote:

> Could someone tag that PR with :+1:?
>
> 2016-11-22 20:41 GMT+01:00 Lukasz Lenart <lu...@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 <lu...@apache.org>:
> >> Done, thanks Aaron :) Now I must test this solution with Google
> AppEngine ;-)
> >>
> >> 2016-11-22 7:49 GMT+01:00 Lukasz Lenart <lu...@apache.org>:
> >>> 2016-11-21 20:12 GMT+01:00 Aaron Johnson <jo...@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
>
>

Re: [jira] [Updated] (WW-4717) Refactor file upload support to allow create virtual representation of java.io.File

Posted by Lukasz Lenart <lu...@apache.org>.
The missing classes are here https://github.com/apache/struts/pull/114
- for now ignore the plugin, first the change must go in

2016-11-23 15:08 GMT+01:00 Greg Huber <gr...@gmail.com>:
> I don't use git, so i have no idea what your are saying PR wise.
>
> From the source:
>
> import org.apache.struts2.dispatcher.multipart.AbstractMultiPartRequest
>
> public class GaeMultiPartRequest extends AbstractMultiPartRequest
>
> ##
>
> so i need the class
> org.apache.struts2.dispatcher.multipart.AbstractMultiPartRequest.java
> to compile it locally.
>
> It should be somewhere where I can download it.
>
>
>
>
> On 23 November 2016 at 13:59, Lukasz Lenart <lu...@apache.org> wrote:
>
>> Yes, first the PR must be merged than the plugin can be used :) I have
>> done that locally and everything is fine. The most important things is
>> that the PR doesn't break backward compatibility :)
>>
>> 2016-11-23 14:52 GMT+01:00 Greg Huber <gr...@gmail.com>:
>> > I have downloaded the plugin to get the source to copy to my server and
>> > these are the ones that are missing, and it won't compile.?
>> >
>> > On 23 November 2016 at 13:48, Lukasz Lenart <lu...@apache.org>
>> wrote:
>> >
>> >> 2016-11-23 14:32 GMT+01:00 Greg Huber <gr...@gmail.com>:
>> >> > where do all these come from?
>> >> >
>> >> > import org.apache.struts2.dispatcher.multipart.UploadedFile;
>> >> > import org.apache.struts2.dispatcher.multipart.
>> AbstractMultiPartRequest;
>> >>
>> >> These are new things added in that PR, where that abstract class is
>> >> just a helper to reduce code duplication - the same as
>> >> AbstractInterceptor
>> >>
>> >> > import org.apache.struts2.dispatcher.multipart.MultiPartRequest;
>> >>
>> >> This interface was already in Struts, it's used to implement different
>> >> approaches - Jakarta, Jakarta Stream, Pell and right now my solution
>> >> supporting GAE
>> >>
>> >>
>> >> 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


Re: [jira] [Updated] (WW-4717) Refactor file upload support to allow create virtual representation of java.io.File

Posted by Greg Huber <gr...@gmail.com>.
I don't use git, so i have no idea what your are saying PR wise.

From the source:

import org.apache.struts2.dispatcher.multipart.AbstractMultiPartRequest

public class GaeMultiPartRequest extends AbstractMultiPartRequest

##

so i need the class
org.apache.struts2.dispatcher.multipart.AbstractMultiPartRequest.java
to compile it locally.

It should be somewhere where I can download it.




On 23 November 2016 at 13:59, Lukasz Lenart <lu...@apache.org> wrote:

> Yes, first the PR must be merged than the plugin can be used :) I have
> done that locally and everything is fine. The most important things is
> that the PR doesn't break backward compatibility :)
>
> 2016-11-23 14:52 GMT+01:00 Greg Huber <gr...@gmail.com>:
> > I have downloaded the plugin to get the source to copy to my server and
> > these are the ones that are missing, and it won't compile.?
> >
> > On 23 November 2016 at 13:48, Lukasz Lenart <lu...@apache.org>
> wrote:
> >
> >> 2016-11-23 14:32 GMT+01:00 Greg Huber <gr...@gmail.com>:
> >> > where do all these come from?
> >> >
> >> > import org.apache.struts2.dispatcher.multipart.UploadedFile;
> >> > import org.apache.struts2.dispatcher.multipart.
> AbstractMultiPartRequest;
> >>
> >> These are new things added in that PR, where that abstract class is
> >> just a helper to reduce code duplication - the same as
> >> AbstractInterceptor
> >>
> >> > import org.apache.struts2.dispatcher.multipart.MultiPartRequest;
> >>
> >> This interface was already in Struts, it's used to implement different
> >> approaches - Jakarta, Jakarta Stream, Pell and right now my solution
> >> supporting GAE
> >>
> >>
> >> 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
>
>

Re: [jira] [Updated] (WW-4717) Refactor file upload support to allow create virtual representation of java.io.File

Posted by Lukasz Lenart <lu...@apache.org>.
Yes, first the PR must be merged than the plugin can be used :) I have
done that locally and everything is fine. The most important things is
that the PR doesn't break backward compatibility :)

2016-11-23 14:52 GMT+01:00 Greg Huber <gr...@gmail.com>:
> I have downloaded the plugin to get the source to copy to my server and
> these are the ones that are missing, and it won't compile.?
>
> On 23 November 2016 at 13:48, Lukasz Lenart <lu...@apache.org> wrote:
>
>> 2016-11-23 14:32 GMT+01:00 Greg Huber <gr...@gmail.com>:
>> > where do all these come from?
>> >
>> > import org.apache.struts2.dispatcher.multipart.UploadedFile;
>> > import org.apache.struts2.dispatcher.multipart.AbstractMultiPartRequest;
>>
>> These are new things added in that PR, where that abstract class is
>> just a helper to reduce code duplication - the same as
>> AbstractInterceptor
>>
>> > import org.apache.struts2.dispatcher.multipart.MultiPartRequest;
>>
>> This interface was already in Struts, it's used to implement different
>> approaches - Jakarta, Jakarta Stream, Pell and right now my solution
>> supporting GAE
>>
>>
>> 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


Re: [jira] [Updated] (WW-4717) Refactor file upload support to allow create virtual representation of java.io.File

Posted by Greg Huber <gr...@gmail.com>.
I have downloaded the plugin to get the source to copy to my server and
these are the ones that are missing, and it won't compile.?

On 23 November 2016 at 13:48, Lukasz Lenart <lu...@apache.org> wrote:

> 2016-11-23 14:32 GMT+01:00 Greg Huber <gr...@gmail.com>:
> > where do all these come from?
> >
> > import org.apache.struts2.dispatcher.multipart.UploadedFile;
> > import org.apache.struts2.dispatcher.multipart.AbstractMultiPartRequest;
>
> These are new things added in that PR, where that abstract class is
> just a helper to reduce code duplication - the same as
> AbstractInterceptor
>
> > import org.apache.struts2.dispatcher.multipart.MultiPartRequest;
>
> This interface was already in Struts, it's used to implement different
> approaches - Jakarta, Jakarta Stream, Pell and right now my solution
> supporting GAE
>
>
> 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
>
>

Re: [jira] [Updated] (WW-4717) Refactor file upload support to allow create virtual representation of java.io.File

Posted by Lukasz Lenart <lu...@apache.org>.
2016-11-23 14:32 GMT+01:00 Greg Huber <gr...@gmail.com>:
> where do all these come from?
>
> import org.apache.struts2.dispatcher.multipart.UploadedFile;
> import org.apache.struts2.dispatcher.multipart.AbstractMultiPartRequest;

These are new things added in that PR, where that abstract class is
just a helper to reduce code duplication - the same as
AbstractInterceptor

> import org.apache.struts2.dispatcher.multipart.MultiPartRequest;

This interface was already in Struts, it's used to implement different
approaches - Jakarta, Jakarta Stream, Pell and right now my solution
supporting GAE


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


Re: [jira] [Updated] (WW-4717) Refactor file upload support to allow create virtual representation of java.io.File

Posted by Greg Huber <gr...@gmail.com>.
where do all these come from?

import org.apache.struts2.dispatcher.multipart.UploadedFile;
import org.apache.struts2.dispatcher.multipart.AbstractMultiPartRequest;
import org.apache.struts2.dispatcher.multipart.MultiPartRequest;


On 23 November 2016 at 12:56, Lukasz Lenart <lu...@apache.org> wrote:

> Could someone tag that PR with :+1:?
>
> 2016-11-22 20:41 GMT+01:00 Lukasz Lenart <lu...@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 <lu...@apache.org>:
> >> Done, thanks Aaron :) Now I must test this solution with Google
> AppEngine ;-)
> >>
> >> 2016-11-22 7:49 GMT+01:00 Lukasz Lenart <lu...@apache.org>:
> >>> 2016-11-21 20:12 GMT+01:00 Aaron Johnson <jo...@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
>
>

Re: [jira] [Updated] (WW-4717) Refactor file upload support to allow create virtual representation of java.io.File

Posted by Lukasz Lenart <lu...@apache.org>.
Could someone tag that PR with :+1:?

2016-11-22 20:41 GMT+01:00 Lukasz Lenart <lu...@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 <lu...@apache.org>:
>> Done, thanks Aaron :) Now I must test this solution with Google AppEngine ;-)
>>
>> 2016-11-22 7:49 GMT+01:00 Lukasz Lenart <lu...@apache.org>:
>>> 2016-11-21 20:12 GMT+01:00 Aaron Johnson <jo...@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


Re: [jira] [Updated] (WW-4717) Refactor file upload support to allow create virtual representation of java.io.File

Posted by Lukasz Lenart <lu...@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 <lu...@apache.org>:
> Done, thanks Aaron :) Now I must test this solution with Google AppEngine ;-)
>
> 2016-11-22 7:49 GMT+01:00 Lukasz Lenart <lu...@apache.org>:
>> 2016-11-21 20:12 GMT+01:00 Aaron Johnson <jo...@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


Re: [jira] [Updated] (WW-4717) Refactor file upload support to allow create virtual representation of java.io.File

Posted by Lukasz Lenart <lu...@apache.org>.
Done, thanks Aaron :) Now I must test this solution with Google AppEngine ;-)

2016-11-22 7:49 GMT+01:00 Lukasz Lenart <lu...@apache.org>:
> 2016-11-21 20:12 GMT+01:00 Aaron Johnson <jo...@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


Re: [jira] [Updated] (WW-4717) Refactor file upload support to allow create virtual representation of java.io.File

Posted by Lukasz Lenart <lu...@apache.org>.
2016-11-21 20:12 GMT+01:00 Aaron Johnson <jo...@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


Re: [jira] [Updated] (WW-4717) Refactor file upload support to allow create virtual representation of java.io.File

Posted by Aaron Johnson <jo...@gmail.com>.
Is it possible to have a converter from UploadedFile to File? The
UploadedFile has a getContent() method that returns the File object.

On Mon, Nov 21, 2016 at 7:28 AM, Christoph Nenning <
Christoph.Nenning@lex-com.net> wrote:

> Surly there will be users complaining. We should at least provide a config
> switch and deprecation warning.
>
>
>
> Regards,
> Christoph
>
>
>
> > From: Lukasz Lenart <lu...@apache.org>
> > To: Struts Developers List <de...@struts.apache.org>,
> > Date: 21.11.2016 10:58
> > Subject: Re: [jira] [Updated] (WW-4717) Refactor file upload support
> > to allow create virtual representation of java.io.File
> >
> > I would like to refactor file upload logic to use a virtual
> > representation of a file but this requires changes in users'
> > applications as well, instead of using java.io.File they will have to
> > switch to UploadedFile Struts class.
> >
> > Not sure if it is worth doing :\
> >
> >
> > Regards
> > --
> > Łukasz
> > + 48 606 323 122 http://www.lenart.org.pl/
> >
> > 2016-11-21 10:09 GMT+01:00 Lukasz Lenart (JIRA) <ji...@apache.org>:
> > >
> > >      [ https://issues.apache.org/jira/browse/WW-4717?
> > page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
> > >
> > > Lukasz Lenart updated WW-4717:
> > > ------------------------------
> > >     Summary: Refactor file upload support to allow create virtual
> > representation of java.io.File  (was: Refactor file upload support
> > to allow create virtual representation of java.ioFile)
> > >
> > >> Refactor file upload support to allow create virtual
> > representation of java.io.File
> > >>
> >
> ------------------------------------------------------------
> -----------------------
> > >>
> > >>                 Key: WW-4717
> > >>                 URL: https://issues.apache.org/jira/browse/WW-4717
> > >>             Project: Struts 2
> > >>          Issue Type: Improvement
> > >>          Components: Core
> > >>    Affects Versions: 2.5.5
> > >>            Reporter: Lukasz Lenart
> > >>            Assignee: Lukasz Lenart
> > >>             Fix For: 2.5.6
> > >>
> > >>
> > >> Right now file upload logic is using {{java.io.File}} directly to
> > represent uploaded files but access to this class is restricted in
> > some cloud environments  e.g. Google AppEngine
> > >
> > >
> > >
> > > --
> > > This message was sent by Atlassian JIRA
> > > (v6.3.4#6332)
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: dev-unsubscribe@struts.apache.org
> > For additional commands, e-mail: dev-help@struts.apache.org
> >
>
> This Email was scanned by Sophos Anti Virus
>

Re: [jira] [Updated] (WW-4717) Refactor file upload support to allow create virtual representation of java.io.File

Posted by Christoph Nenning <Ch...@lex-com.net>.
Surly there will be users complaining. We should at least provide a config 
switch and deprecation warning.



Regards,
Christoph



> From: Lukasz Lenart <lu...@apache.org>
> To: Struts Developers List <de...@struts.apache.org>, 
> Date: 21.11.2016 10:58
> Subject: Re: [jira] [Updated] (WW-4717) Refactor file upload support
> to allow create virtual representation of java.io.File
> 
> I would like to refactor file upload logic to use a virtual
> representation of a file but this requires changes in users'
> applications as well, instead of using java.io.File they will have to
> switch to UploadedFile Struts class.
> 
> Not sure if it is worth doing :\
> 
> 
> Regards
> -- 
> Łukasz
> + 48 606 323 122 http://www.lenart.org.pl/
> 
> 2016-11-21 10:09 GMT+01:00 Lukasz Lenart (JIRA) <ji...@apache.org>:
> >
> >      [ https://issues.apache.org/jira/browse/WW-4717?
> page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
> >
> > Lukasz Lenart updated WW-4717:
> > ------------------------------
> >     Summary: Refactor file upload support to allow create virtual 
> representation of java.io.File  (was: Refactor file upload support 
> to allow create virtual representation of java.ioFile)
> >
> >> Refactor file upload support to allow create virtual 
> representation of java.io.File
> >> 
> 
-----------------------------------------------------------------------------------
> >>
> >>                 Key: WW-4717
> >>                 URL: https://issues.apache.org/jira/browse/WW-4717
> >>             Project: Struts 2
> >>          Issue Type: Improvement
> >>          Components: Core
> >>    Affects Versions: 2.5.5
> >>            Reporter: Lukasz Lenart
> >>            Assignee: Lukasz Lenart
> >>             Fix For: 2.5.6
> >>
> >>
> >> Right now file upload logic is using {{java.io.File}} directly to
> represent uploaded files but access to this class is restricted in 
> some cloud environments  e.g. Google AppEngine
> >
> >
> >
> > --
> > This message was sent by Atlassian JIRA
> > (v6.3.4#6332)
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe@struts.apache.org
> For additional commands, e-mail: dev-help@struts.apache.org
> 

This Email was scanned by Sophos Anti Virus