From fa1a40c637b32ba80b09f0d455211d778a21aef1 Mon Sep 17 00:00:00 2001 From: LittleSheep Date: Tue, 18 Nov 2025 01:06:02 +0800 Subject: [PATCH] :sparkles: File references listing endpoint --- DysonNetwork.Drive/Storage/FileController.cs | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/DysonNetwork.Drive/Storage/FileController.cs b/DysonNetwork.Drive/Storage/FileController.cs index a4eeb06..9f0e04c 100644 --- a/DysonNetwork.Drive/Storage/FileController.cs +++ b/DysonNetwork.Drive/Storage/FileController.cs @@ -16,7 +16,8 @@ public class FileController( FileService fs, QuotaService qs, IConfiguration configuration, - IWebHostEnvironment env + IWebHostEnvironment env, + FileReferenceService fileReferenceService ) : ControllerBase { [HttpGet("{id}")] @@ -231,6 +232,21 @@ public class FileController( return file; } + [HttpGet("{id}/references")] + public async Task>> 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] [HttpPatch("{id}/name")] public async Task> UpdateFileName(string id, [FromBody] string name)