public static SaveResult DirectFileSave(Guid userId, FileUpload fuFile, string rootFile, WikiSection section, string configLocation, int tenantId, HttpContext context) { if (!fuFile.HasFile) { return(SaveResult.FileEmpty); } var wikiEngine = new WikiEngine(); File file = null; try { file = wikiEngine.CreateOrUpdateFile(new File { FileName = fuFile.FileName, FileSize = fuFile.FileBytes.Length }); FileContentSave(file.FileLocation, fuFile.FileBytes, section, configLocation, tenantId, context); } catch (TenantQuotaException) { if (file != null) { wikiEngine.RemoveFile(file.FileName); } return(SaveResult.FileSizeExceeded); } return(SaveResult.Ok); }
public static SaveResult DirectFileSave(Guid UserId, string _fileName, byte[] _fileContent, string rootFile, WikiSection section, string configLocation, int tenantId, HttpContext context, out string outFileName) { outFileName = string.Empty; //var fileName = _fileName; //var fileLocation = GetFileLocation(fileName, section, rootFile); //var file = new File // { // FileName = fileName, // UploadFileName = fileName, // UserID = UserId, // FileLocation = fileLocation, // FileSize = _fileContent.Length // }; var wikiEngine = new WikiEngine(); //wikiEngine.SaveFile(file); var file = wikiEngine.CreateOrUpdateFile(new File { FileName = _fileName, FileSize = _fileContent.Length }); try { FileContentSave(file.FileLocation /*fileLocation*/, _fileContent, section, configLocation, tenantId, context); } catch (TenantQuotaException) { wikiEngine.RemoveFile(file.FileName); return(SaveResult.FileSizeExceeded); } outFileName = file.FileName; return(SaveResult.Ok); }
public IEnumerable <FileWrapper> UploadFiles(IEnumerable <System.Web.HttpPostedFileBase> files) { if (files == null || !files.Any()) { throw new ArgumentNullException("files"); } return(files.Select(file => new FileWrapper(_engine.CreateOrUpdateFile(new File { FileName = file.FileName, FileSize = file.ContentLength, UploadFileName = file.FileName }, file.InputStream)))); }
public static SaveResult DirectFileSave(Guid UserId, FileUpload fuFile, string rootFile, WikiSection section, string configLocation, int tenantId, HttpContext context) { if (!fuFile.HasFile) { return(SaveResult.FileEmpty); } //var fileName = fuFile.FileName; //var fileLocation = GetFileLocation(fileName, section, rootFile); //var file = new File // { // FileName = fileName, // UploadFileName = fileName, // UserID = UserId, // FileLocation = fileLocation, // FileSize = fuFile.FileBytes.Length, // }; var wikiEngine = new WikiEngine(); //wikiEngine.SaveFile(file); var file = wikiEngine.CreateOrUpdateFile(new File { FileName = fuFile.FileName, FileSize = fuFile.FileBytes.Length }); try { FileContentSave(file.FileLocation /*fileLocation*/, fuFile.FileBytes, section, configLocation, tenantId, context); } catch (TenantQuotaException) { wikiEngine.RemoveFile(file.FileName); return(SaveResult.FileSizeExceeded); } return(SaveResult.Ok); }
public static SaveResult DirectFileSave(Guid UserId, FileUpload fuFile, string rootFile, WikiSection section, string configLocation, int tenantId, HttpContext context) { if (!fuFile.HasFile) return SaveResult.FileEmpty; //var fileName = fuFile.FileName; //var fileLocation = GetFileLocation(fileName, section, rootFile); //var file = new File // { // FileName = fileName, // UploadFileName = fileName, // UserID = UserId, // FileLocation = fileLocation, // FileSize = fuFile.FileBytes.Length, // }; var wikiEngine = new WikiEngine(); //wikiEngine.SaveFile(file); var file = wikiEngine.CreateOrUpdateFile(new File {FileName = fuFile.FileName, FileSize = fuFile.FileBytes.Length}); try { FileContentSave(file.FileLocation/*fileLocation*/, fuFile.FileBytes, section, configLocation, tenantId, context); } catch (TenantQuotaException) { wikiEngine.RemoveFile(file.FileName); return SaveResult.FileSizeExceeded; } return SaveResult.Ok; }
public static SaveResult DirectFileSave(Guid userId, FileUpload fuFile, string rootFile, WikiSection section, string configLocation, int tenantId, HttpContext context) { if (!fuFile.HasFile) return SaveResult.FileEmpty; var wikiEngine = new WikiEngine(); File file = null; try { file = wikiEngine.CreateOrUpdateFile(new File {FileName = fuFile.FileName, FileSize = fuFile.FileBytes.Length}); FileContentSave(file.FileLocation, fuFile.FileBytes, section, configLocation, tenantId, context); } catch (TenantQuotaException) { if (file != null) wikiEngine.RemoveFile(file.FileName); return SaveResult.FileSizeExceeded; } return SaveResult.Ok; }