Vista combinada Visión Plana Vista de árbol
Discusiones [ Anterior | Siguiente ]
sepideh tajeri
create mp3 file
8 de mayo de 2012 22:03
Respuesta

sepideh tajeri

Ranking: Junior Member

Mensajes: 32

Fecha de incorporación: 30 de octubre de 2011

Mensajes recientes

Hi all,
I write a portlet that text convert to mp3 file.
this portlet convert text to sound but it can not write byte of file to a mp3 file.
I define below code:
response.setContentType("audio/mp3");
response.addProperty(HttpHeaders.CONTENT_DISPOSITION, "attachment; filename=sample.mp3");
response.setBufferSize(mp3.length);
OutputStream out1=response.getPortletOutputStream();
out1.write(mp3);
out1.flush();
out1.close();

this output of portlet is added to the attachment file.
Plz help me for how to write byte code to mp3 file and download this file.
Adjunto

archivos adjuntos: Capture.PNG (56,0k)
David H Nebinger
RE: create mp3 file
8 de mayo de 2012 22:12
Respuesta

David H Nebinger

Community Moderator

Ranking: Liferay Legend

Mensajes: 11511

Fecha de incorporación: 1 de septiembre de 2006

Mensajes recientes

You cannot use the portlet output stream to send back binary data to the browser.

The only way you can do this is through a resource request to the portlet.
sepideh tajeri
RE: create mp3 file
8 de mayo de 2012 22:48
Respuesta

sepideh tajeri

Ranking: Junior Member

Mensajes: 32

Fecha de incorporación: 30 de octubre de 2011

Mensajes recientes

Thx for your answer.
I send text from jsp to serveResource() function and i take text with request.getParameter(). then convert text to mp3 file,
atlast I want to mp3 file change to byte, such as below code:
byte[] mp3 = new byte[file.available()]; // file is mp3 file
and I put byte to response and download file.
this program is corrected when I just use servlet, and out of liferay.
Has liferay special configuration for download mp3 file?