dwr - upload file and download file in one request
Question
is it possible to upload a file and subsequently when receiving response download the file,
I mean in one request I'll upload a file and download the file in one action?
Solution 2
Yes It's possible to do that at least in dwr 3.
OTHER TIPS
Maybe this demo code will be helpful for you: http://directwebremoting.org/dwr-demo/simple/download.html
An example which return a excel to download from client:
//Java side:
public FileTransfer getExcel(Parametros param){
byte[] result = <here get data>;
InputStream myInputStream = new ByteArrayInputStream(result);
String excelFormat = "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet";
FileTransfer dwrExcelFile = new FileTransfer("excel.xlsx", excelFormat, myInputStream);
return dwrExcelFile;
}
//Javascript side:
function downloadExcelFile() {
dwr.engine.setTimeout(59000);
var params = <params_to_send>;
<Java_class>.getExcel(params, {callback:function(dataFromServer) {
downloadExcelCallback(dataFromServer);
}});
}
function downloadExcelCallback(data) {
dwr.engine.openInDownload(data);
}
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow