I have a Struts 2 action and Struts 2 on a SERVER SIDE so the user can upload files from my application.
Files are stored inside the database (I know ... but keep focus). The user gets access to the action, I get the file from the database and send it to the user using Stream.
@Action(value="getFile", results= {
@Result(name="ok", type="stream", params = {
"contentType", "application/octet-stream",
"inputName", "fileInputStream",
"contentDisposition", "filename=\"${fileName}\"",
"bufferSize", "1024"
}) }
)
...
public class GetFileAction {
private String fileName;
private Integer idFile;
private ByteArrayInputStream fileInputStream;
public String execute () {
...
try {
FileService fs = new FileService();
if ( (idFile != null) && ( idFile > -1 ) ) {
file = fs.getFile( idFile );
}
if ( file != null ) {
byte[] theFile = file.getFile();
fileInputStream = new ByteArrayInputStream( theFile );
fileName = file.getFileName();
} else {
}
} catch ( Exception e ) {
}
...
Everything works the way I want, but I want to control (from my Tomcat container - SERVER SIDE, not the user browser) from the server side, the user loading process ...
Is it possible?
Thank.
source
share