/// <summary> /// 构造函数,指定存储文件夹 /// </summary> /// <param name="OldName">旧文件名</param> /// <param name="ContentLength">文件大小</param> /// <param name="UploadPath">上传文件夹</param> public UploadInfo(string OldName, int ContentLength, string UploadPath) { this.OldName = OldName; this.ContentLength = ContentLength; this.NewName = UploadInfo.CreateNewName(Extention); this.UploadPath = UploadPath; }
/// <summary> /// 构造函数 /// 需要加载WebConfig中的上传节点 /// </summary> /// <param name="OldName">旧文件名</param> /// <param name="ContentLength">文件大小</param> public UploadInfo(string OldName, int ContentLength, bool IsRename) { this.OldName = OldName; this.ContentLength = ContentLength; //如果是第一次创建链接需要创建新名称 if (IsRename) { this.NewName = UploadInfo.CreateNewName(Extention); } else { this.NewName = OldName; } //加载配置文件中上传文件夹 this.UploadPath = GetUploadFiles(); }
/// <summary> /// 根据客户端json信息,创建 /// </summary> /// <param name="upMsg"></param> public UploadInfo(UploadMsg upMsg, string AbolutePath = null) { this.OldName = upMsg.OldName; this.ContentLength = upMsg.Size; if (string.IsNullOrEmpty(upMsg.NewName)) { this.NewName = UploadInfo.CreateNewName(Extention); } else { this.NewName = upMsg.NewName; } _UploadMsg = upMsg; if (upMsg.HandleType == HandleType.自动处理.GetHashCode()) { //自动模式,上传到网站upload文件夹 this.UploadPath = new AutoHandle(upMsg.SubFolder).GetAbsolutePath(); } else if (upMsg.HandleType == HandleType.简单处理.GetHashCode()) { //简单处理模式,直接保存到指定uploadpath中 if (string.IsNullOrEmpty(AbolutePath)) { //获取配置文件中的目录 string configPath = GetUploadFiles(); if (string.IsNullOrEmpty(upMsg.SubFolder) == false) { configPath += upMsg.SubFolder; } if (Directory.Exists(configPath) == false) { Directory.CreateDirectory(configPath); } this.UploadPath = configPath; } else { this.UploadPath = AbolutePath; } } else //如果是带临时处理的,保存到临时文件夹 { //加载配置文件中上传文件夹 this.UploadPath = GetTempFile(); } }
/// <summary> /// 根据客户端json信息,创建 /// </summary> /// <param name="upMsg"></param> public UploadInfo(UploadMsg upMsg, string AbolutePath = null) { this.OldName = upMsg.OldName; this.ContentLength = upMsg.Size; if (string.IsNullOrEmpty(upMsg.NewName)) { this.NewName = UploadInfo.CreateNewName(Extention); } else { this.NewName = upMsg.NewName; } _UploadMsg = upMsg; if (upMsg.HandleType == HandleType.自动处理.GetHashCode()) { //自动模式,上传到网站upload文件夹 this.UploadPath = new AutoHandle(upMsg.SubFolder).GetAbsolutePath(); } else if (upMsg.HandleType == HandleType.简单处理.GetHashCode()) { //简单处理模式,直接保存到指定uploadpath中 if (string.IsNullOrEmpty(AbolutePath)) { //获取配置文件中的目录 this.UploadPath = ServerInfo.GetSub(upMsg.SubFolder);; } else { this.UploadPath = AbolutePath; } } else //如果是带临时处理的,保存到临时文件夹 { //加载配置文件中上传文件夹 this.UploadPath = GetTempFile(); } }