public ActionResult Add(UserEditInfo user) { try { string partialPath = CustomerEnumDesc.GetResxTypePath(ResxType.UserHeadImage); ImageHandler resx = new ImageHandler { ResxTypes = ResxConfigManager.IMAGE_FILE_TYPES, ResxSize = ResxConfigManager.IMAGE_MAX_SIZE, IsThumbnail = false, SaveLocalDirectory = string.Format("{0}{1}", AppConfigManager.UploadDirectory, partialPath), AccessUrl = string.Format("{0}{1}", ResxConfigManager.FileAccessUrl, partialPath) }; ResxImageResult result = resx.Upload(Request.Form.Files.FirstOrDefault()); if (!result.Success) { return(Json(new { state = -1, error = result.Message })); } else { user.HeadImage = result.ResxAccessUrl; } int userId = userService.AddUser(user); if (userId <= 0) { return(Json(new { state = -1, error = "Create user failed." })); } } catch (Exception ex) { return(Json(new { state = -1, error = ex.Message })); } return(Json(new { state = 1 })); }
public override ResxUploadResponseBody ExecuteCore() { string partialPath = CustomerEnumDesc.GetResxTypePath(request.ResxType, request.UserId); ResxHandler resx = new ResxHandler { SaveLocalDirectory = string.Format("{0}{1}", AppConfigManager.UploadDirectory, partialPath), AccessUrl = string.Format("{0}{1}", ResxConfigManager.FileAccessUrl, partialPath) }; ResxResult result = resx.Upload(request.Files.FirstOrDefault()); return(new ResxUploadResponseBody() { ResxResult = result }); }
public override VideoUploadResponseBody ExecuteCore() { string partialPath = CustomerEnumDesc.GetResxTypePath(request.ResxType, request.UserId); VideoHandler resx = new VideoHandler { ResxTypes = ResxConfigManager.VIDEO_FILE_TYPES, ResxSize = ResxConfigManager.VIDEO_MAX_SIZE, IsThumbnail = true, SaveLocalDirectory = string.Format("{0}{1}", AppConfigManager.UploadDirectory, partialPath), AccessUrl = string.Format("{0}{1}", ResxConfigManager.FileAccessUrl, partialPath) }; ResxVideoResult result = resx.Upload(request.Files.FirstOrDefault()); return(new VideoUploadResponseBody() { ResxVideoResult = result }); }
private void Init() { if (this.resxModel == null) { throw new Exception("资源属性不能为空"); } if (this.resxModel.ResxTypes == null || this.resxModel.ResxTypes.Length <= 0) { throw new Exception("需要指定上传资源的类型"); } string dir = ResxConfigManager.UploadDirectory + CustomerEnumDesc.GetResxTypePath(this.resxModel.ResxType, this.resxModel.UserId); rootDir = AppDomain.CurrentDomain.BaseDirectory + dir; accessDir = ResxConfigManager.FileAccessUrl + dir; if (!Directory.Exists(rootDir)) { Directory.CreateDirectory(rootDir); } }