コード例 #1
0
 public void salvarArquivo() throws IOException {
   UploadedFile arq = file;
   if (arq != null) {
     saidaFinanceiro.setArquivo(new Arquivo());
     saidaFinanceiro.getArquivo().setDescricao(arq.getFileName());
     saidaFinanceiro.getArquivo().setContentType(arq.getContentType());
     saidaFinanceiro.getArquivo().setTamanho(arq.getSize());
     saidaFinanceiro.getArquivo().setConteudo(arq.getContents());
   }
 }
コード例 #2
0
 public void download() {
   InputStream stream =
       ((ServletContext) FacesContext.getCurrentInstance().getExternalContext().getContext())
           .getResourceAsStream(saidaFinanceiro.getArquivo().getDescricao());
   fileDownload = new DefaultStreamedContent(stream, saidaFinanceiro.getArquivo().getDescricao());
 }