Image upload problem with more than 10mb primefaces

Asked

Viewed 654 times

1

Guys, I’m going through a very boring and seemingly simple problem and I haven’t found a solution yet, so can someone help me? I’m using the upload of the first faces and it just doesn’t upload files larger than 10mb... A 9.9mb file will be normal. = o

I wonder where I change to raise this limit?

Follow the code I’m using:

<p:fileUpload multiple="false"  cancelLabel="Cancelar" label="Selecionar Brasão..." fileUploadListener="#{back.uploadArquivo}" mode="advanced" dragDropSupport="true" auto="false" 
         fileLimit="1" sizeLimit="51380224"    update="panel_grid_upload_arquivo, :growl" />

back:

  public void uploadArquivo(FileUploadEvent event) {
    DocumentoEntity arquivo = new DocumentoEntity();
    try {
        arquivo.setArquivo(IOUtils.toByteArray(event.getFile().getInputstream()));
        arquivo.setNomeArquivo(event.getFile().getFileName());
        arquivo.setNome(event.getFile().getFileName());
        this.arquivo = arquivo;
        exibirMensagemSucesso("Upload feito com sucesso", "O arquivo agora está associado ao documento");
    } catch (IOException e) {
        exibirMensagemErro("Ocorreu algum erro", "Ocorreu algum erro e o upload não pôde ser feito");
        LOGGER.error("Não realizou o upload do arquivo");
        e.printStackTrace();
    }

}

my web.xml is with these settings:

<filter>
<filter-name>PrimeFaces FileUpload Filter</filter-name>
<filter-class>org.primefaces.webapp.filter.FileUploadFilter</filter-class>
</filter>
<filter-mapping>
<filter-name>PrimeFaces FileUpload Filter</filter-name>
<servlet-name>Faces Servlet</servlet-name>
</filter-mapping>

A file bigger than 10mb doesn’t even get into the bean. From now on I appreciate any help!

  • Which application server you are using?

1 answer

2

I discovered the problem after a few hours... and it was really quite simple. This error happened because of wildfly 8! Since it limits the maximum size of the "post" settings. I had to put max-post-size="50485760" on standalone.xml and now it works normal.

So was the stretch of standalone.xml:

<server name="default-server">
        <http-listener name="default" socket-binding="http" max-post-size="50485760"/>
        <host name="default-host" alias="localhost">
            <location name="/" handler="welcome-content"/>
            <filter-ref name="server-header"/>
            <filter-ref name="x-powered-by-header"/>
        </host>
    </server>

Browser other questions tagged

You are not signed in. Login or sign up in order to post.