Re: improve documentation for UploadedFilesAware

2024-03-25 Thread Łukasz Lenart
pon., 25 mar 2024 o 10:00 Greg Huber  napisał(a):
>
> OK great.  More of a chance of it being read .

Thanks, merged

> I guess this new version includes all the "old versions" security stuff
> from past issues, and is not a new code base.

Yes, it only uses a different mechanism to pass uploaded files from
within the interceptor to an action.

> As the old one is deprecated, and we all rush and upgrade, their may be
> more resources put in trying to break it.  Maybe better to wait a bit
> before upgrading?

The new approach directly addresses all the previous vulnerabilities
where the attacker was able to manipulate the file upload process by
overriding parameters via setters. Migrating to this new mechanism is
safer than staying with the old mechanism. Even if a new vulnerability
will be discovered it will be way easier to fix it as your actions
depend on the interface only.


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

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



Re: improve documentation for UploadedFilesAware

2024-03-25 Thread Greg Huber

OK great.  More of a chance of it being read .

I guess this new version includes all the "old versions" security stuff 
from past issues, and is not a new code base.


As the old one is deprecated, and we all rush and upgrade, their may be 
more resources put in trying to break it.  Maybe better to wait a bit 
before upgrading?


On 24/03/2024 20:47, Lukasz Lenart wrote:

pon., 18 mar 2024 o 14:42 Greg Huber  napisał(a):

OK...I did not spot the link in the text.

I repeated the links in the Examples sections of both


Cheers
Lukasz

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


Re: improve documentation for UploadedFilesAware

2024-03-24 Thread Lukasz Lenart
pon., 18 mar 2024 o 14:42 Greg Huber  napisał(a):
>
> OK...I did not spot the link in the text.

I repeated the links in the Examples sections of both


Cheers
Lukasz

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



Re: improve documentation for UploadedFilesAware

2024-03-18 Thread Greg Huber
OK...I did not spot the link in the text.


On Mon, 18 Mar 2024 at 12:59, Łukasz Lenart  wrote:

> pon., 18 mar 2024 o 13:05 Greg Huber  napisał(a):
> >
> > > See [this page] for more examples and advanced configuration.
> >
> > Which page?
>
> On these pages, a very first sentence
>
> https://struts.staged.apache.org/core-developers/action-file-upload-interceptor
> https://struts.staged.apache.org/core-developers/file-upload-interceptor
>
> > > I reverted this idea and UploadedFile isn't generic.
> >
> > that would be in 7.0.0_M4?  I used _M3 to test it.
>
> Yes, I need to reverse merge master and push M4
>
>
> Cheers
> Lukasz
>
> -
> To unsubscribe, e-mail: dev-unsubscr...@struts.apache.org
> For additional commands, e-mail: dev-h...@struts.apache.org
>
>


Re: improve documentation for UploadedFilesAware

2024-03-18 Thread Łukasz Lenart
pon., 18 mar 2024 o 13:05 Greg Huber  napisał(a):
>
> > See [this page] for more examples and advanced configuration.
>
> Which page?

On these pages, a very first sentence
https://struts.staged.apache.org/core-developers/action-file-upload-interceptor
https://struts.staged.apache.org/core-developers/file-upload-interceptor

> > I reverted this idea and UploadedFile isn't generic.
>
> that would be in 7.0.0_M4?  I used _M3 to test it.

Yes, I need to reverse merge master and push M4


Cheers
Lukasz

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



Re: improve documentation for UploadedFilesAware

2024-03-18 Thread Greg Huber

See [this page] for more examples and advanced configuration.


Which page?


I reverted this idea and UploadedFile isn't generic.


that would be in 7.0.0_M4?  I used _M3 to test it.

On 18/03/2024 11:56, Lukasz Lenart wrote:

pon., 18 mar 2024 o 08:21 Greg Huber  napisał(a):

Rechecking these :

Could not see the link from from the interceptor pages to these detailed
help pages.  Add a link after Examples?

File Upload Interceptor

  Parameters
  Extending the Interceptor
  Examples


Or at the bottom of the page?

The links are in the very first sentence:
See [this page] for more examples and advanced configuration.


There is a UploadedFile is a raw type. References to generic type
UploadedFile should be parameterized warning

I reverted this idea and UploadedFile isn't generic.


Cheers
Łukasz

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



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



Re: improve documentation for UploadedFilesAware

2024-03-18 Thread Lukasz Lenart
pon., 18 mar 2024 o 08:21 Greg Huber  napisał(a):
>
> Rechecking these :
>
> Could not see the link from from the interceptor pages to these detailed
> help pages.  Add a link after Examples?
>
> File Upload Interceptor
>
>  Parameters
>  Extending the Interceptor
>  Examples
>
>
> Or at the bottom of the page?

The links are in the very first sentence:
See [this page] for more examples and advanced configuration.

>
> There is a UploadedFile is a raw type. References to generic type
> UploadedFile should be parameterized warning

I reverted this idea and UploadedFile isn't generic.


Cheers
Łukasz

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



Re: improve documentation for UploadedFilesAware

2024-03-18 Thread Greg Huber

Rechecking these :

Could not see the link from from the interceptor pages to these detailed 
help pages.  Add a link after Examples?


File Upload Interceptor

    Parameters
    Extending the Interceptor
    Examples


Or at the bottom of the page?

#

There is a UploadedFile is a raw type. References to generic type 
UploadedFile should be parameterized warning


private List uploadedFiles = new ArrayList<>();
private List> uploadedFiles = new ArrayList<>();

|@Override public void withUploadedFiles(List uploads) { }|

@Override public void withUploadedFiles(List> arg0) { }

On 17/03/2024 16:46, Lukasz Lenart wrote:

Added :) Also adjusted the Showcasehttps://github.com/apache/struts/pull/895

niedz., 17 mar 2024 o 12:29 Greg Huber  napisał(a):

Looks good, but what happened to the examples with the stream stuff?

Something like this for MultipleFileUploadUsingArrayActionusing arrays
example?


public class MultipleFileUploadUsingArrayAction extends ActionSupport
  implements UploadedFilesAware {

  private List> uploads = null;

  public String upload() throws Exception {
  System.out.println("\n\n upload2");
  System.out.println("files:");

  for (UploadedFile uploadedFile : this.uploads) {
  System.out.println("*** " + uploadedFile.getOriginalName()
+ "\t"
  + uploadedFile.getContentType() + "\t"
  + uploadedFile.length());
  }
  System.out.println("filenames:");
  String[] uploadFileNames = getUploadedFilesFileNames();
  for (String n : uploadFileNames) {
  System.out.println("*** " + n);
  }
  System.out.println("content types:");
  String[] uploadContentTypes = getUploadedFilesContentType();
  for (String c : uploadContentTypes) {
  System.out.println("*** " + c);
  }
  System.out.println("\n\n");
  return SUCCESS;
  }

  @Override
  public void withUploadedFiles(List> uploadedFiles) {
  this.uploads = uploadedFiles;
  }

  private String[] getUploadedFilesFileNames() {
  return this.uploads.stream().map(UploadedFile::getOriginalName)
  .toArray(size -> new String[size]);
  }

  private String[] getUploadedFilesContentType() {
  return this.uploads.stream().map(UploadedFile::getContentType)
  .toArray(size -> new String[size]);
  }
}


On 17/03/2024 09:33, Lukasz Lenart wrote:

Better?
https://struts.staged.apache.org/core-developers/action-file-upload
https://struts.staged.apache.org/core-developers/file-upload

czw., 14 mar 2024 o 15:29 Greg Huber   napisał(a):

Sorry, I meant we need to copy/duplicate this page :

https://struts.apache.org/core-developers/file-upload.html

to an *action* version:

https://struts.apache.org/core-developers/action-file-upload.html

and modify it for the new interceptor methods/logic

On Thu, 14 Mar 2024 at 12:42, Łukasz Lenart   wrote:


Done
https://github.com/apache/struts-site/pull/231

czw., 14 mar 2024 o 11:35 Greg Huber   napisał(a):

There is a really good page for the old upload

https://struts.apache.org/core-developers/file-upload.html

But the << back to Core Developers Guide does not make it easy to find
it again.

##

https://struts.apache.org/core-developers/action-file-upload-interceptor

would benefit a similar detail page, updated and with the stream stuff.

return

this.uploadedFiles.stream().map(UploadedFile::getContentType).toArray();

otherwise without streams

List>uploads =this.uploadedFiles;

if(uploads !=null&()>0){

for(inti =0;i 
pon., 26 lut 2024 o 12:08 Greg Hubernapisał(a):

The documentation only lists one file

|public void withUploadedFiles(List uploadedFiles) { if
(!uploadedFiles.isEmpty()) { this.uploadedFile = uploadedFiles.get(0);
this.fileName = uploadedFile.getName(); this.contentType =
uploadedFile.getContentType(); this.originalName =
uploadedFile.getOriginalName(); } }|

For multiple files these need populating

privateFile[]uploadedFiles=null;

privateString[]uploadedFilesContentType=null;

privateString[]uploadedFilesFileName=null;

We have to loop and do it ourselves now?

Basically it would be better to stop using additional fields if not
needed. You can achieve the same behaviour just exposing getters
extracting what's needed from "uploadedFiles", eg:

public void withUploadedFiles(List uploadedFiles) {
 this.uploadedFiles = uploadedFiles;
}

public String[] getUploadedFilesContentType() {
 return

this.uploadedFiles.stream().map(UploadedFile::getContentType).toArray();

}

etc.


Cheers
Lukasz

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


-
To unsubscribe,e-mail:dev-unsubscr...@struts.apache.org
For 

Re: improve documentation for UploadedFilesAware

2024-03-17 Thread Lukasz Lenart
Added :) Also adjusted the Showcase https://github.com/apache/struts/pull/895

niedz., 17 mar 2024 o 12:29 Greg Huber  napisał(a):
>
> Looks good, but what happened to the examples with the stream stuff?
>
> Something like this for MultipleFileUploadUsingArrayActionusing arrays
> example?
>
>
> public class MultipleFileUploadUsingArrayAction extends ActionSupport
>  implements UploadedFilesAware {
>
>  private List> uploads = null;
>
>  public String upload() throws Exception {
>  System.out.println("\n\n upload2");
>  System.out.println("files:");
>
>  for (UploadedFile uploadedFile : this.uploads) {
>  System.out.println("*** " + uploadedFile.getOriginalName()
> + "\t"
>  + uploadedFile.getContentType() + "\t"
>  + uploadedFile.length());
>  }
>  System.out.println("filenames:");
>  String[] uploadFileNames = getUploadedFilesFileNames();
>  for (String n : uploadFileNames) {
>  System.out.println("*** " + n);
>  }
>  System.out.println("content types:");
>  String[] uploadContentTypes = getUploadedFilesContentType();
>  for (String c : uploadContentTypes) {
>  System.out.println("*** " + c);
>  }
>  System.out.println("\n\n");
>  return SUCCESS;
>  }
>
>  @Override
>  public void withUploadedFiles(List> uploadedFiles) {
>  this.uploads = uploadedFiles;
>  }
>
>  private String[] getUploadedFilesFileNames() {
>  return this.uploads.stream().map(UploadedFile::getOriginalName)
>  .toArray(size -> new String[size]);
>  }
>
>  private String[] getUploadedFilesContentType() {
>  return this.uploads.stream().map(UploadedFile::getContentType)
>  .toArray(size -> new String[size]);
>  }
> }
>
>
> On 17/03/2024 09:33, Lukasz Lenart wrote:
> > Better?
> > https://struts.staged.apache.org/core-developers/action-file-upload
> > https://struts.staged.apache.org/core-developers/file-upload
> >
> > czw., 14 mar 2024 o 15:29 Greg Huber  napisał(a):
> >> Sorry, I meant we need to copy/duplicate this page :
> >>
> >> https://struts.apache.org/core-developers/file-upload.html
> >>
> >> to an *action* version:
> >>
> >> https://struts.apache.org/core-developers/action-file-upload.html
> >>
> >> and modify it for the new interceptor methods/logic
> >>
> >> On Thu, 14 Mar 2024 at 12:42, Łukasz Lenart  
> >> wrote:
> >>
> >>> Done
> >>> https://github.com/apache/struts-site/pull/231
> >>>
> >>> czw., 14 mar 2024 o 11:35 Greg Huber  napisał(a):
>  There is a really good page for the old upload
> 
>  https://struts.apache.org/core-developers/file-upload.html
> 
>  But the << back to Core Developers Guide does not make it easy to find
>  it again.
> 
>  ##
> 
>  https://struts.apache.org/core-developers/action-file-upload-interceptor
> 
>  would benefit a similar detail page, updated and with the stream stuff.
> 
>  return
> >>> this.uploadedFiles.stream().map(UploadedFile::getContentType).toArray();
>  otherwise without streams
> 
>  List>uploads =this.uploadedFiles;
> 
>  if(uploads !=null&()>0){
> 
>  for(inti =0;i  
>  String file uploads.get(i).getOriginalName();
> 
>  // destroy the temporary file created
> 
>  uploads.get(i).delete();
> 
>  }
> 
>  }
> 
>  On 12/03/2024 19:48, Lukasz Lenart wrote:
> > pon., 26 lut 2024 o 12:08 Greg Huber   napisał(a):
> >> The documentation only lists one file
> >>
> >> |public void withUploadedFiles(List uploadedFiles) { if
> >> (!uploadedFiles.isEmpty()) { this.uploadedFile = uploadedFiles.get(0);
> >> this.fileName = uploadedFile.getName(); this.contentType =
> >> uploadedFile.getContentType(); this.originalName =
> >> uploadedFile.getOriginalName(); } }|
> >>
> >> For multiple files these need populating
> >>
> >> privateFile[]uploadedFiles=null;
> >>
> >> privateString[]uploadedFilesContentType=null;
> >>
> >> privateString[]uploadedFilesFileName=null;
> >>
> >> We have to loop and do it ourselves now?
> > Basically it would be better to stop using additional fields if not
> > needed. You can achieve the same behaviour just exposing getters
> > extracting what's needed from "uploadedFiles", eg:
> >
> > public void withUploadedFiles(List uploadedFiles) {
> > this.uploadedFiles = uploadedFiles;
> > }
> >
> > public String[] getUploadedFilesContentType() {
> > return
> >>> this.uploadedFiles.stream().map(UploadedFile::getContentType).toArray();
> > }
> >
> > etc.
> >
> >
> > Cheers
> > Lukasz
> >
> > -
> > To 

Re: improve documentation for UploadedFilesAware

2024-03-17 Thread Greg Huber

Looks good, but what happened to the examples with the stream stuff?

Something like this for MultipleFileUploadUsingArrayActionusing arrays 
example?



public class MultipleFileUploadUsingArrayAction extends ActionSupport
    implements UploadedFilesAware {

    private List> uploads = null;

    public String upload() throws Exception {
    System.out.println("\n\n upload2");
    System.out.println("files:");

    for (UploadedFile uploadedFile : this.uploads) {
        System.out.println("*** " + uploadedFile.getOriginalName() 
+ "\t"

                + uploadedFile.getContentType() + "\t"
                + uploadedFile.length());
    }
    System.out.println("filenames:");
    String[] uploadFileNames = getUploadedFilesFileNames();
    for (String n : uploadFileNames) {
        System.out.println("*** " + n);
    }
    System.out.println("content types:");
    String[] uploadContentTypes = getUploadedFilesContentType();
    for (String c : uploadContentTypes) {
        System.out.println("*** " + c);
    }
    System.out.println("\n\n");
    return SUCCESS;
    }

    @Override
    public void withUploadedFiles(List> uploadedFiles) {
    this.uploads = uploadedFiles;
    }

    private String[] getUploadedFilesFileNames() {
    return this.uploads.stream().map(UploadedFile::getOriginalName)
            .toArray(size -> new String[size]);
    }

    private String[] getUploadedFilesContentType() {
    return this.uploads.stream().map(UploadedFile::getContentType)
            .toArray(size -> new String[size]);
    }
}


On 17/03/2024 09:33, Lukasz Lenart wrote:

Better?
https://struts.staged.apache.org/core-developers/action-file-upload
https://struts.staged.apache.org/core-developers/file-upload

czw., 14 mar 2024 o 15:29 Greg Huber  napisał(a):

Sorry, I meant we need to copy/duplicate this page :

https://struts.apache.org/core-developers/file-upload.html

to an *action* version:

https://struts.apache.org/core-developers/action-file-upload.html

and modify it for the new interceptor methods/logic

On Thu, 14 Mar 2024 at 12:42, Łukasz Lenart  wrote:


Done
https://github.com/apache/struts-site/pull/231

czw., 14 mar 2024 o 11:35 Greg Huber  napisał(a):

There is a really good page for the old upload

https://struts.apache.org/core-developers/file-upload.html

But the << back to Core Developers Guide does not make it easy to find
it again.

##

https://struts.apache.org/core-developers/action-file-upload-interceptor

would benefit a similar detail page, updated and with the stream stuff.

return

this.uploadedFiles.stream().map(UploadedFile::getContentType).toArray();

otherwise without streams

List>uploads =this.uploadedFiles;

if(uploads !=null&()>0){

for(inti =0;i 
pon., 26 lut 2024 o 12:08 Greg Huber   napisał(a):

The documentation only lists one file

|public void withUploadedFiles(List uploadedFiles) { if
(!uploadedFiles.isEmpty()) { this.uploadedFile = uploadedFiles.get(0);
this.fileName = uploadedFile.getName(); this.contentType =
uploadedFile.getContentType(); this.originalName =
uploadedFile.getOriginalName(); } }|

For multiple files these need populating

privateFile[]uploadedFiles=null;

privateString[]uploadedFilesContentType=null;

privateString[]uploadedFilesFileName=null;

We have to loop and do it ourselves now?

Basically it would be better to stop using additional fields if not
needed. You can achieve the same behaviour just exposing getters
extracting what's needed from "uploadedFiles", eg:

public void withUploadedFiles(List uploadedFiles) {
this.uploadedFiles = uploadedFiles;
}

public String[] getUploadedFilesContentType() {
return

this.uploadedFiles.stream().map(UploadedFile::getContentType).toArray();

}

etc.


Cheers
Lukasz

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


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



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


Re: improve documentation for UploadedFilesAware

2024-03-17 Thread Lukasz Lenart
Better?
https://struts.staged.apache.org/core-developers/action-file-upload
https://struts.staged.apache.org/core-developers/file-upload

czw., 14 mar 2024 o 15:29 Greg Huber  napisał(a):
>
> Sorry, I meant we need to copy/duplicate this page :
>
> https://struts.apache.org/core-developers/file-upload.html
>
> to an *action* version:
>
> https://struts.apache.org/core-developers/action-file-upload.html
>
> and modify it for the new interceptor methods/logic
>
> On Thu, 14 Mar 2024 at 12:42, Łukasz Lenart  wrote:
>
> > Done
> > https://github.com/apache/struts-site/pull/231
> >
> > czw., 14 mar 2024 o 11:35 Greg Huber  napisał(a):
> > >
> > > There is a really good page for the old upload
> > >
> > > https://struts.apache.org/core-developers/file-upload.html
> > >
> > > But the << back to Core Developers Guide does not make it easy to find
> > > it again.
> > >
> > > ##
> > >
> > > https://struts.apache.org/core-developers/action-file-upload-interceptor
> > >
> > > would benefit a similar detail page, updated and with the stream stuff.
> > >
> > > return
> > this.uploadedFiles.stream().map(UploadedFile::getContentType).toArray();
> > >
> > > otherwise without streams
> > >
> > > List>uploads =this.uploadedFiles;
> > >
> > > if(uploads !=null&()>0){
> > >
> > > for(inti =0;i  > >
> > > String file uploads.get(i).getOriginalName();
> > >
> > > // destroy the temporary file created
> > >
> > > uploads.get(i).delete();
> > >
> > > }
> > >
> > > }
> > >
> > > On 12/03/2024 19:48, Lukasz Lenart wrote:
> > > > pon., 26 lut 2024 o 12:08 Greg Huber  napisał(a):
> > > >> The documentation only lists one file
> > > >>
> > > >> |public void withUploadedFiles(List uploadedFiles) { if
> > > >> (!uploadedFiles.isEmpty()) { this.uploadedFile = uploadedFiles.get(0);
> > > >> this.fileName = uploadedFile.getName(); this.contentType =
> > > >> uploadedFile.getContentType(); this.originalName =
> > > >> uploadedFile.getOriginalName(); } }|
> > > >>
> > > >> For multiple files these need populating
> > > >>
> > > >> privateFile[]uploadedFiles=null;
> > > >>
> > > >> privateString[]uploadedFilesContentType=null;
> > > >>
> > > >> privateString[]uploadedFilesFileName=null;
> > > >>
> > > >> We have to loop and do it ourselves now?
> > > > Basically it would be better to stop using additional fields if not
> > > > needed. You can achieve the same behaviour just exposing getters
> > > > extracting what's needed from "uploadedFiles", eg:
> > > >
> > > > public void withUploadedFiles(List uploadedFiles) {
> > > >this.uploadedFiles = uploadedFiles;
> > > > }
> > > >
> > > > public String[] getUploadedFilesContentType() {
> > > >return
> > this.uploadedFiles.stream().map(UploadedFile::getContentType).toArray();
> > > > }
> > > >
> > > > etc.
> > > >
> > > >
> > > > Cheers
> > > > Lukasz
> > > >
> > > > -
> > > > To unsubscribe, e-mail:dev-unsubscr...@struts.apache.org
> > > > For additional commands, e-mail:dev-h...@struts.apache.org
> > > >
> >
> > -
> > To unsubscribe, e-mail: dev-unsubscr...@struts.apache.org
> > For additional commands, e-mail: dev-h...@struts.apache.org
> >
> >

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



Re: improve documentation for UploadedFilesAware

2024-03-14 Thread Greg Huber
Sorry, I meant we need to copy/duplicate this page :

https://struts.apache.org/core-developers/file-upload.html

to an *action* version:

https://struts.apache.org/core-developers/action-file-upload.html

and modify it for the new interceptor methods/logic

On Thu, 14 Mar 2024 at 12:42, Łukasz Lenart  wrote:

> Done
> https://github.com/apache/struts-site/pull/231
>
> czw., 14 mar 2024 o 11:35 Greg Huber  napisał(a):
> >
> > There is a really good page for the old upload
> >
> > https://struts.apache.org/core-developers/file-upload.html
> >
> > But the << back to Core Developers Guide does not make it easy to find
> > it again.
> >
> > ##
> >
> > https://struts.apache.org/core-developers/action-file-upload-interceptor
> >
> > would benefit a similar detail page, updated and with the stream stuff.
> >
> > return
> this.uploadedFiles.stream().map(UploadedFile::getContentType).toArray();
> >
> > otherwise without streams
> >
> > List>uploads =this.uploadedFiles;
> >
> > if(uploads !=null&()>0){
> >
> > for(inti =0;i  >
> > String file uploads.get(i).getOriginalName();
> >
> > // destroy the temporary file created
> >
> > uploads.get(i).delete();
> >
> > }
> >
> > }
> >
> > On 12/03/2024 19:48, Lukasz Lenart wrote:
> > > pon., 26 lut 2024 o 12:08 Greg Huber  napisał(a):
> > >> The documentation only lists one file
> > >>
> > >> |public void withUploadedFiles(List uploadedFiles) { if
> > >> (!uploadedFiles.isEmpty()) { this.uploadedFile = uploadedFiles.get(0);
> > >> this.fileName = uploadedFile.getName(); this.contentType =
> > >> uploadedFile.getContentType(); this.originalName =
> > >> uploadedFile.getOriginalName(); } }|
> > >>
> > >> For multiple files these need populating
> > >>
> > >> privateFile[]uploadedFiles=null;
> > >>
> > >> privateString[]uploadedFilesContentType=null;
> > >>
> > >> privateString[]uploadedFilesFileName=null;
> > >>
> > >> We have to loop and do it ourselves now?
> > > Basically it would be better to stop using additional fields if not
> > > needed. You can achieve the same behaviour just exposing getters
> > > extracting what's needed from "uploadedFiles", eg:
> > >
> > > public void withUploadedFiles(List uploadedFiles) {
> > >this.uploadedFiles = uploadedFiles;
> > > }
> > >
> > > public String[] getUploadedFilesContentType() {
> > >return
> this.uploadedFiles.stream().map(UploadedFile::getContentType).toArray();
> > > }
> > >
> > > etc.
> > >
> > >
> > > Cheers
> > > Lukasz
> > >
> > > -
> > > To unsubscribe, e-mail:dev-unsubscr...@struts.apache.org
> > > For additional commands, e-mail:dev-h...@struts.apache.org
> > >
>
> -
> To unsubscribe, e-mail: dev-unsubscr...@struts.apache.org
> For additional commands, e-mail: dev-h...@struts.apache.org
>
>


Re: improve documentation for UploadedFilesAware

2024-03-14 Thread Łukasz Lenart
Done
https://github.com/apache/struts-site/pull/231

czw., 14 mar 2024 o 11:35 Greg Huber  napisał(a):
>
> There is a really good page for the old upload
>
> https://struts.apache.org/core-developers/file-upload.html
>
> But the << back to Core Developers Guide does not make it easy to find
> it again.
>
> ##
>
> https://struts.apache.org/core-developers/action-file-upload-interceptor
>
> would benefit a similar detail page, updated and with the stream stuff.
>
> return 
> this.uploadedFiles.stream().map(UploadedFile::getContentType).toArray();
>
> otherwise without streams
>
> List>uploads =this.uploadedFiles;
>
> if(uploads !=null&()>0){
>
> for(inti =0;i 
> String file uploads.get(i).getOriginalName();
>
> // destroy the temporary file created
>
> uploads.get(i).delete();
>
> }
>
> }
>
> On 12/03/2024 19:48, Lukasz Lenart wrote:
> > pon., 26 lut 2024 o 12:08 Greg Huber  napisał(a):
> >> The documentation only lists one file
> >>
> >> |public void withUploadedFiles(List uploadedFiles) { if
> >> (!uploadedFiles.isEmpty()) { this.uploadedFile = uploadedFiles.get(0);
> >> this.fileName = uploadedFile.getName(); this.contentType =
> >> uploadedFile.getContentType(); this.originalName =
> >> uploadedFile.getOriginalName(); } }|
> >>
> >> For multiple files these need populating
> >>
> >> privateFile[]uploadedFiles=null;
> >>
> >> privateString[]uploadedFilesContentType=null;
> >>
> >> privateString[]uploadedFilesFileName=null;
> >>
> >> We have to loop and do it ourselves now?
> > Basically it would be better to stop using additional fields if not
> > needed. You can achieve the same behaviour just exposing getters
> > extracting what's needed from "uploadedFiles", eg:
> >
> > public void withUploadedFiles(List uploadedFiles) {
> >this.uploadedFiles = uploadedFiles;
> > }
> >
> > public String[] getUploadedFilesContentType() {
> >return 
> > this.uploadedFiles.stream().map(UploadedFile::getContentType).toArray();
> > }
> >
> > etc.
> >
> >
> > Cheers
> > Lukasz
> >
> > -
> > To unsubscribe, e-mail:dev-unsubscr...@struts.apache.org
> > For additional commands, e-mail:dev-h...@struts.apache.org
> >

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



Re: improve documentation for UploadedFilesAware

2024-03-14 Thread Greg Huber

There is a really good page for the old upload

https://struts.apache.org/core-developers/file-upload.html

But the << back to Core Developers Guide does not make it easy to find 
it again.


##

https://struts.apache.org/core-developers/action-file-upload-interceptor

would benefit a similar detail page, updated and with the stream stuff.

return this.uploadedFiles.stream().map(UploadedFile::getContentType).toArray();

otherwise without streams

List>uploads =this.uploadedFiles;

if(uploads !=null&()>0){

for(inti =0;i 
pon., 26 lut 2024 o 12:08 Greg Huber  napisał(a):

The documentation only lists one file

|public void withUploadedFiles(List uploadedFiles) { if
(!uploadedFiles.isEmpty()) { this.uploadedFile = uploadedFiles.get(0);
this.fileName = uploadedFile.getName(); this.contentType =
uploadedFile.getContentType(); this.originalName =
uploadedFile.getOriginalName(); } }|

For multiple files these need populating

privateFile[]uploadedFiles=null;

privateString[]uploadedFilesContentType=null;

privateString[]uploadedFilesFileName=null;

We have to loop and do it ourselves now?

Basically it would be better to stop using additional fields if not
needed. You can achieve the same behaviour just exposing getters
extracting what's needed from "uploadedFiles", eg:

public void withUploadedFiles(List uploadedFiles) {
   this.uploadedFiles = uploadedFiles;
}

public String[] getUploadedFilesContentType() {
   return 
this.uploadedFiles.stream().map(UploadedFile::getContentType).toArray();
}

etc.


Cheers
Lukasz

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


Re: improve documentation for UploadedFilesAware

2024-03-12 Thread Lukasz Lenart
pon., 26 lut 2024 o 12:08 Greg Huber  napisał(a):
>
> The documentation only lists one file
>
> |public void withUploadedFiles(List uploadedFiles) { if
> (!uploadedFiles.isEmpty()) { this.uploadedFile = uploadedFiles.get(0);
> this.fileName = uploadedFile.getName(); this.contentType =
> uploadedFile.getContentType(); this.originalName =
> uploadedFile.getOriginalName(); } }|
>
> For multiple files these need populating
>
> privateFile[]uploadedFiles=null;
>
> privateString[]uploadedFilesContentType=null;
>
> privateString[]uploadedFilesFileName=null;
>
> We have to loop and do it ourselves now?

Basically it would be better to stop using additional fields if not
needed. You can achieve the same behaviour just exposing getters
extracting what's needed from "uploadedFiles", eg:

public void withUploadedFiles(List uploadedFiles) {
  this.uploadedFiles = uploadedFiles;
}

public String[] getUploadedFilesContentType() {
  return 
this.uploadedFiles.stream().map(UploadedFile::getContentType).toArray();
}

etc.


Cheers
Lukasz

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