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