Delete files in batch API

This commit is contained in:
2025-11-18 20:33:02 +08:00
parent faa375042a
commit 587066d847
2 changed files with 33 additions and 2 deletions

View File

@@ -333,6 +333,22 @@ public class FileController(
return Ok(files);
}
public class FileBatchDeletionRequest
{
public List<string> FileIds { get; set; } = [];
}
[Authorize]
[HttpPost("batches/delete")]
public async Task<ActionResult> DeleteFileBatch([FromBody] FileBatchDeletionRequest request)
{
if (HttpContext.Items["CurrentUser"] is not Account currentUser) return Unauthorized();
var userId = Guid.Parse(currentUser.Id);
var count = await fs.DeleteAccountFileBatchAsync(userId, request.FileIds);
return Ok(new { Count = count });
}
[Authorize]
[HttpDelete("{id}")]
public async Task<ActionResult<SnCloudFile>> DeleteFile(string id)
@@ -371,4 +387,4 @@ public class FileController(
var count = await fs.DeleteAllRecycledFilesAsync();
return Ok(new { Count = count });
}
}
}