private MenuItem downloadItem;
+ private MenuItem saveAsItem;
+
/**
* The image bundle for this widget's images that reuses images defined in
* other menus.
if(currentFolder!=null && currentFolder.getUserObject() instanceof FolderResource)
contextMenu.addItem(updateItem);
String[] link = {"", ""};
- gss.getTopPanel().getFileMenu().createDownloadLink(link);
+ gss.getTopPanel().getFileMenu().createDownloadLink(link, false);
downloadItem = new MenuItem("<span>" + link[0] + newImages.download().getHTML() + " Download" + link[1] + "</span>", true, downloadCmd);
contextMenu.addItem(downloadItem);
+ gss.getTopPanel().getFileMenu().createDownloadLink(link, true);
+ saveAsItem = new MenuItem("<span>" + link[0] + newImages.download().getHTML() + " Save file as" + link[1] + "</span>", true, downloadCmd);
+ contextMenu.addItem(saveAsItem);
contextMenu.addItem(cutItem);
contextMenu.addItem(copyItem);
if(currentFolder!=null && currentFolder.getUserObject() instanceof FolderResource)
* @param link a String array with two elements that is modified so that the\r
* first position contains the opening tag and the second one the\r
* closing tag\r
+ * @param forceDownload If true, link will be such that browser should ask for filename\r
+ * and save location\r
*/\r
- void createDownloadLink(String[] link) {\r
+ void createDownloadLink(String[] link, boolean forceDownload) {\r
GSS app = GSS.get();\r
Object selection = app.getCurrentSelection();\r
if (selection != null && selection instanceof FileResource) {\r
String dateString = RestCommand.getDate();\r
String resource = file.getUri().substring(app.getApiPath().length()-1,file.getUri().length());\r
String sig = app.getCurrentUserResource().getUsername()+" "+RestCommand.calculateSig("GET", dateString, resource, RestCommand.base64decode(app.getToken()));\r
- link[0] = "<a class='hidden-link' href='" + file.getUri() + "?Authorization=" + URL.encodeComponent(sig) + "&Date="+URL.encodeComponent(dateString) + "' target='_blank'>";\r
+ link[0] = "<a class='hidden-link' href='" + file.getUri() + "?Authorization=" + URL.encodeComponent(sig) + "&Date="+URL.encodeComponent(dateString)\r
+ + (forceDownload ? "&dl=1" : "") + "' target='_blank'>";\r
link[1] = "</a>";\r
}\r
}\r
if (uploadVisible) contextMenu.addItem("<span>" + images.fileUpdate().getHTML() + " Upload</span>", true, new UploadFileCommand(this, images));\r
if (downloadVisible) {\r
String[] link = {"", ""};\r
- createDownloadLink(link);\r
+ createDownloadLink(link, false);\r
contextMenu.addItem("<span>" + link[0] + images.download().getHTML() + " Download" + link[1] + "</span>", true, downloadCmd);\r
+ createDownloadLink(link, true);\r
+ contextMenu.addItem("<span>" + link[0] + images.download().getHTML() + " Save file as" + link[1] + "</span>", true, downloadCmd);\r
}\r
contextMenu.addItem("<span>" + images.emptyTrash().getHTML() + " Empty Trash</span>", true, new EmptyTrashCommand(this));\r
contextMenu.addItem("<span>" + images.refresh().getHTML() + " Refresh</span>", true, new RefreshCommand(this, images));\r
// Silent catch
}
try {
- if(file != null && needsContentDisposition(req))
- resp.setHeader("Content-Disposition","attachment; filename=\""+file.getName()+"\"");
+ if(file != null)
+ if (needsContentDisposition(req))
+ resp.setHeader("Content-Disposition","attachment; filename*=UTF-8''"+URLEncoder.encode(file.getName(),"UTF-8"));
+ else
+ resp.setHeader("Content-Disposition","inline; filename*=UTF-8''"+URLEncoder.encode(file.getName(),"UTF-8"));
if (ostream != null)
copy(file, renderResult, ostream, req, oldBody);
else
* @return true if the Content-Disposition HTTP header must be set
*/
private boolean needsContentDisposition(HttpServletRequest req) {
- String agent = req.getHeader("user-agent");
+ /*String agent = req.getHeader("user-agent");
if (agent != null && agent.contains("MSIE"))
+ return true;*/
+ String dl = req.getParameter("dl");
+ if ("1".equals(dl))
return true;
return false;
}