これはフォーラムでの私の最初の質問です。これで私を助けてくれることを願っています。 私の余談:
- ブラウザからダウンロードしたい基本のファイル
- 私はprimefaces、FileDownload、およびStreamedContentを使用しています
問題
問題は、ファイル 0 バイトをダウンロードすることです。
私のview.xhtml:
<p:commandButton id="downloadLink" value="Descargar" ajax="false" onclick="PrimeFaces.monitorDownload(start, stop)"
rendered="#{not anexoController.ingresaDatos}" icon="ui-icon-arrowthichk-s">
<p:fileDownload value="#{anexoController.file}" />
</p:commandButton>
私のダウンロードマネージャー
public StreamedContent getFile() {
file = null;
byte[] bytes = anexoActual.getArchivo(); //anexoActual.getArchivo.length = 53508
String nombre = anexoActual.getNombre();
String formato = anexoActual.getFormato();
InputStream stream = new ByteArrayInputStream(bytes);
try {
stream.read(bytes);
} catch (IOException ex) {
Logger.getLogger(AnexoController.class.getName()).log(Level.SEVERE, null, ex);
}
file = new DefaultStreamedContent(stream, formato, nombre);
return file; //file.steam.buf.length = 53508
}
ご覧のとおり、ファイルは 53508 バイトの長さのファイルに到達しますが、ダウンロードが完了すると、ファイル名とデータ型しかわかりません