public FileManager(MonitoringConfig config, ILogger logger, ShareFolder shareFolder, IMetricServer metricServer) { _shareFolder = shareFolder; _config = config; _logger = logger; _metricServer = metricServer; }
public async Task <ActionResult <FolderItem> > EditFolderShare(Guid uuid, [FromBody] EditFileSystemItemShareBody body) { try { await ValidateFileSystemItemShare(body); } catch (HttpResultException exc) { return(exc.Result); } if (await dbContext.ShareFolders.AnyAsync(f => f.Uuid != uuid && f.Name == body.Name && f.UserId == body.UserId)) { return(BadRequest("Folder with this name is already shared")); } ShareFolder shareFolder = await dbContext.ShareFolders .Include(f => f.Permission) .FirstOrDefaultAsync(f => f.Uuid == uuid); if (shareFolder == null) { return(NotFound("Share folder not found")); } shareFolder.Name = body.Name; shareFolder.IsListed = body.IsListed; shareFolder.UserId = body.UserId; await dbContext.SaveChangesAsync(); return(shareFolder.ToFolderItem()); }
public async Task <ActionResult <ShareItem> > GetShareFolder(Guid uuid) { ShareFolder shareFolder = await dbContext.ShareFolders .Include(f => f.Permission) .FirstOrDefaultAsync(f => f.Uuid == uuid); if (shareFolder == null) { return(NotFound("Share folder not found")); } return(shareFolder.ToShareItem()); }
public async Task <ActionResult> DeleteShareFolder(Guid uuid) { ShareFolder shareFolder = await dbContext.ShareFolders .Include(f => f.Permission) .FirstOrDefaultAsync(f => f.Uuid == uuid); if (shareFolder == null) { return(NotFound("Share folder not found")); } dbContext.ShareFolders.Remove(shareFolder); await dbContext.SaveChangesAsync(); return(Ok()); }
public async Task <ActionResult <FolderItem> > AddFolderShare([FromBody] AddFolderShareBody body) { InternalFolder folder; try { folder = await ValidateAddFolderShare(body); } catch (HttpResultException exc) { return(exc.Result); } if (!HasPermission(folder.Permission, body.Permission)) { return(Forbid()); } if (!string.IsNullOrWhiteSpace(folder.PhysicalPath) && !System.IO.Directory.Exists(folder.PhysicalPath)) { return(NotFound("Folder not found")); } if (body.UserId != null && !await dbContext.Users.AnyAsync(u => u.Id == body.UserId)) { return(BadRequest("User not found")); } if (await dbContext.ShareFolders.AnyAsync(f => f.Name == body.Name && f.UserId == body.UserId)) { return(BadRequest("Folder with this name is already shared")); } ShareFolder shareFolder = new ShareFolder() { Name = body.Name, Path = folder.PhysicalPath, IsListed = body.IsListed, UserId = body.UserId, Permission = Models.FolderItemPermission.New(body.Permission), }; await dbContext.ShareFolders.AddAsync(shareFolder); await dbContext.SaveChangesAsync(); return(shareFolder.ToFolderItem()); }
public static async Task <InternalFolder> GetFolderItem(string virtualPath, AppDbContext dbContext, string userId, ControllerBase controller) { string[] parts = Utils.SplitPath(virtualPath); if (!Guid.TryParse(parts[0], out Guid uuid)) { throw (HttpResultException)controller.BadRequest("Can't parse uuid"); } ShareFolder folder = await dbContext.ShareFolders .Include(f => f.Permission) .FirstOrDefaultAsync(f => f.Uuid == uuid); if (folder == null || (folder.UserId != null && folder.UserId != userId)) { throw (HttpResultException)controller.NotFound("Share folder not found."); } Guid?sharedId = null; IEnumerable <string> allPhysicalPathParts = new string[] { folder.Path }.Concat(parts[1..]);
private void create_button_Click(object sender, EventArgs e) { if (textBox1.Text == "") { MessageBox.Show("Please enter the folder name"); return; } ShareFolder sf = new ShareFolder(); StringBuilder sb = new StringBuilder(); inputList.Add(new KeyValuePair <TextBox, CheckBox>(textBox2, checkBox1)); //inputList.Add(textBox2, checkBox1); foreach (KeyValuePair <TextBox, CheckBox> kvp in inputList) { if (kvp.Key.Text != "") { sb.Append(kvp.Key.Text + (kvp.Value.Checked == true ? " RW," : " R,")); } } if (!sf.createSharedFolder(clientForm.getEmailId, textBox1.Text, sb.ToString().TrimEnd(','))) { MessageBox.Show("ERROR creating Shared Folder"); return; } //String cloudPublicPath = Environment.GetFolderPath(Environment.SpecialFolder.Desktop) + "\\DBLite\\Public"; //bool isExists = System.IO.Directory.Exists((cloudPublicPath)); //if (!isExists) //{ // System.IO.Directory.CreateDirectory((cloudPublicPath)); //} //System.IO.Directory.CreateDirectory((cloudPublicPath + "\\" + textBox1.Text)); clientForm.displayCloud(); this.Dispose(); }
public static async Task <InternalFile> GetFileItem(string virtualPath, AppDbContext dbContext, string userId, ControllerBase controller) { string[] parts = Utils.SplitPath(virtualPath); if (!Guid.TryParse(parts[0], out Guid uuid)) { throw (HttpResultException)controller.BadRequest("Can't parse uuid"); } if (parts.Length == 1) { ShareFile shareFile = await dbContext.ShareFiles .Include(f => f.Permission) .FirstOrDefaultAsync(f => f.Uuid == uuid); if (shareFile == null || (shareFile.UserId != null && shareFile.UserId != userId)) { throw (HttpResultException)controller.NotFound("Share file not found."); } return(new InternalFile() { PhysicalPath = shareFile.Path, VirtualPath = virtualPath, Name = shareFile.Name, SharedId = shareFile.Uuid, Permission = shareFile.Permission.ToFileItemPermission(), }); } ShareFolder folder = await dbContext.ShareFolders .Include(f => f.Permission) .FirstOrDefaultAsync(f => f.Uuid == uuid); if (folder == null || (folder.UserId != null && folder.UserId != userId)) { throw (HttpResultException)controller.NotFound("Share folder not found."); } IEnumerable <string> allPhysicalPathParts = new string[] { folder?.Path }.Concat(parts[1..]);