Skip to content

Commit

Permalink
allow filename to be empty
Browse files Browse the repository at this point in the history
  • Loading branch information
chsami committed Jul 31, 2024
1 parent 6922c5f commit 9638fff
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 6 deletions.
7 changes: 3 additions & 4 deletions MicrobotApi/Controllers/FileController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -50,15 +50,14 @@ public async Task<IActionResult> Download(Guid fileName, string key, string hwid
}*/


[HttpGet("list/{environment}/{fileName}")]
public async Task<IActionResult> List(string environment, string fileName)
[HttpGet("list/{environment}")]
public async Task<IActionResult> List(string environment, [FromQuery] string? fileName)
{
var fileNames = await _azureStorageService.GetFileNames(environment, fileName);

return Ok(fileNames);

}

[HttpGet("download/{path}")]
public async Task<IActionResult> Download(string path)
{
Expand Down
4 changes: 2 additions & 2 deletions MicrobotApi/Services/AzureStorageService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ public async Task<Uri> GetDownloadUrl(string storagePath)
return sasUri;
}

public async Task<List<string>> GetFileNames(string storagePath, string fileName)
public async Task<List<string>> GetFileNames(string storagePath, string? fileName)
{
var containerClient = _blobServiceClient.GetBlobContainerClient(BlobContainer);

Expand All @@ -68,7 +68,7 @@ public async Task<List<string>> GetFileNames(string storagePath, string fileName
// List blobs in the container
await foreach (BlobItem blobItem in containerClient.GetBlobsAsync(prefix: storagePath))
{
if (blobItem.Name.Contains(fileName))
if (string.IsNullOrWhiteSpace(fileName) || blobItem.Name.Contains(fileName))
{
fileNames.Add(blobItem.Name);
}
Expand Down

0 comments on commit 9638fff

Please sign in to comment.