I am trying to play video file, for my action contentType is set to
application/octet-stream
now if i change it to audio/mpeg, t
Of course you can.
You must output the Stream Result type from your Action, and specify a parametric contentType, for example:
Struts.xml
${yourContentType}
inputStream
attachment;filename="${yourFileName}"
1024
Action
@Getter @Setter private InputStream inputStream;
@Getter private String yourContentType;
@Getter private String yourFileName;
public String execute() throws Exception {
yourContentType = "audio/mpeg";
yourFileName = "yourStuff.mp3";
byte[] yourContent = loadTheContentInSomeWay();
setInputStream(new ByteArrayInputStream(yourContent));
return SUCCESS;
}
You can parameterize the contentDisposition
part to specify when a file must be opened as attachment
(ask for download) or inline
(open in browser) according to your needs.