1
这是我在论坛中的第一个问题,希望你能帮助我解决这个问题。 我escenary:StreamedContent:下载完成,但文件为空
- 的基础上的文件,我想从一个浏览器下载
- 我使用primefaces,FileDownload和StreamedContent
问题
问题是,下载一个文件0Bytes
我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>
我DownloadManger
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个字节长度的文件,但是当下载完成的唯一东西,我有文件名和数据类型
谢谢!问题解决了,事实是,我意识到这个代码,因为离开了许多变化。 – 2012-08-01 15:47:24