首页 > 其他分享 >公开访问并下载附件文件的方法

公开访问并下载附件文件的方法

时间:2022-09-30 18:34:38浏览次数:55  
标签:obj string FATTACHMENTNAME FATTACHMENT 访问 Add FRELATIVEPATH 附件 下载

http://221.1.215.178:38091/K3cloud/WanHuaFiles\Doc\2022\c203040a68794e98ab33034c2c0bb7c8.xlsx

 

 private JArray GetAttachment(Context ctx, string FBILLTYPE, string FBILLNO)
        {
            JArray attachments = new JArray();
            string sql = string.Format(@"  SELECT  FATTACHMENTNAME ,
                                                    FATTACHMENT ,
                                                    FRELATIVEPATH
                                            FROM    T_BAS_ATTACHMENT ,
                                                    T_BAS_FILESERVERFILEINFO
                                            WHERE   T_BAS_ATTACHMENT.FFILEID = T_BAS_FILESERVERFILEINFO.FFILEID
                                                    AND FBILLTYPE = '{0}'
                                                    AND FBILLNO = '{1}'", FBILLTYPE, FBILLNO);
            var rows = DBUtils.ExecuteDynamicObject(ctx, sql);
            foreach (var row in rows)
            {
                string FATTACHMENTNAME = row["FATTACHMENTNAME"].ToString();//附件名称
                string FRELATIVEPATH = row["FRELATIVEPATH"].ToString();//相对路径
                string url = KDConfiguration.Current.CurrentSiteUrl + "WanHuaFiles" + FRELATIVEPATH;
                string FATTACHMENT = "";
                byte[] tmp = row["FATTACHMENT"] as byte[];
                if (tmp != null)
                    FATTACHMENT = Convert.ToBase64String(tmp);//附件数据转为BASE64字符串
                JObject obj = new JObject();
                obj.Add("FATTACHMENTNAME", FATTACHMENTNAME);
                obj.Add("FATTACHMENT", FATTACHMENT);
                obj.Add("FURL", url);
                attachments.Add(obj);
            }
            return attachments;
        }

 

标签:obj,string,FATTACHMENTNAME,FATTACHMENT,访问,Add,FRELATIVEPATH,附件,下载
From: https://www.cnblogs.com/zouhuaxin/p/16745813.html

相关文章