下载附件
/// <summary> /// 弹出下载提示窗,下载文件至客户端本地。 /// </summary> public void ShowDownload() { string _fileId = "7da03cadfb764f92a492d112f1568ca2"; string url = FileServerHelper.GetAppSiteOuterNetUrl(this.Context, HttpContext.Current.Request); //fileId文件编码可由 T_BAS_ATTACHMENT 附件明细表查得,此处直接拿上面上传文件的编码来做示例。 string fileurl = string.Format("{0}FileUpLoadServices/download.aspx?fileId={1}&token={2}", url, _fileId, this.Context.UserToken); //http://127.0.0.1/K3Cloud/FileUpLoadServices/download.aspx?fileId=7da03cadfb764f92a492d112f1568ca2&token=cf99615d-21ec-4646-bfee-5144da1b6e20 JSONObject jObject = new JSONObject(); jObject.Put("url", HttpUtility.UrlEncode(fileurl)); jObject.Put("title", "文件下载"); jObject.Put("desc", "请点击打开附件:"); jObject.Put("urltitle", "这是文件名"); this.View.AddAction(JSAction.openUrlWindow, new JSONArray { jObject }); }
此方法仅限于在K3系统内部访问, 外部系统访问会提示需要先登录的问题, 用户token在iis重启后也会变化, 所以不适合作为长久的外部链接