File references listing endpoint

This commit is contained in:
2025-11-18 01:06:02 +08:00
parent d43ce7cb11
commit fa1a40c637

View File

@@ -16,7 +16,8 @@ public class FileController(
FileService fs, FileService fs,
QuotaService qs, QuotaService qs,
IConfiguration configuration, IConfiguration configuration,
IWebHostEnvironment env IWebHostEnvironment env,
FileReferenceService fileReferenceService
) : ControllerBase ) : ControllerBase
{ {
[HttpGet("{id}")] [HttpGet("{id}")]
@@ -231,6 +232,21 @@ public class FileController(
return file; return file;
} }
[HttpGet("{id}/references")]
public async Task<ActionResult<List<Shared.Models.CloudFileReference>>> GetFileReferences(string id)
{
var file = await fs.GetFileAsync(id);
if (file is null) return NotFound("File not found.");
// Check if user has access to the file
var accessResult = await ValidateFileAccess(file, null);
if (accessResult is not null) return accessResult;
// Get references using the injected FileReferenceService
var references = await fileReferenceService.GetReferencesAsync(id);
return Ok(references);
}
[Authorize] [Authorize]
[HttpPatch("{id}/name")] [HttpPatch("{id}/name")]
public async Task<ActionResult<SnCloudFile>> UpdateFileName(string id, [FromBody] string name) public async Task<ActionResult<SnCloudFile>> UpdateFileName(string id, [FromBody] string name)