Пример #1
0
        /// <summary>
        /// 分块上传文件
        /// </summary>
        /// <param name="userInfo">用户</param>
        /// <param name="folderId">文件夹主键</param>
        /// <param name="fileName">文件名</param>
        /// <param name="file">文件</param>
        /// <param name="enabled">有效</param>
        /// <returns>主键</returns>
        public string UplaodeByBlock(BaseUserInfo userInfo, string folderId, string fileName, byte[] file, int filesize, bool enabled)
        {
            string result = string.Empty;

            var parameter = ServiceInfo.Create(userInfo, MethodBase.GetCurrentMethod());

            ServiceUtil.ProcessUserCenterReadDb(userInfo, parameter, (dbHelper) =>
            {
                var fileManager = new BaseFileManager(dbHelper, userInfo);
                //上传到磁盘
                if (BaseSystemInfo.UploadStorageMode == "Disk")
                {
                    result = fileManager.UplaodeByBlock(folderId, BaseSystemInfo.UploadPath, fileName, null, filesize, enabled);
                    CreateBlankFile(fileName, filesize);
                    UploadFileChunkBytes(file, 0, fileName);
                }
                else
                {
                    result = fileManager.UplaodeByBlock(folderId, BaseSystemInfo.UploadPath, fileName, file, filesize, enabled);
                }
            });
            return(result);
        }