Skip to content

Commit

Permalink
asdsa
Browse files Browse the repository at this point in the history
  • Loading branch information
mark-175 committed Jan 21, 2025
1 parent c8881b2 commit bb4e4bf
Showing 1 changed file with 14 additions and 9 deletions.
23 changes: 14 additions & 9 deletions CargoHub/Controllers/MigrationsController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,15 @@

namespace CargoHub.Controllers
{
[AuthorizationFilter]

[Route("api/v2/[Controller]")]
public class MigrationsController : ControllerBase
{
private readonly MigrationsService _migrationService;

public MigrationsController(MigrationsService Migrate)
public MigrationsController(MigrationsService migrationsService)
{
_migrationService = migrationService;
_migrationService = migrationsService;
}

[HttpPost()]
Expand All @@ -23,17 +23,22 @@ public async Task<IActionResult> Migrate([FromQuery] string FolderName)
try
{
// Construct the local file path
var localFilePath = Path.Combine(Directory.GetCurrentDirectory(), "Logs", _migrationService.ReadDataFolder(folderName));
var localFilePath = Path.Combine(Directory.GetCurrentDirectory(), "Logs", _migrationService.ReadDataFolder(FolderName));

if (string.IsNullOrEmpty(localFilePath) || !System.IO.File.Exists(localFilePath))
{
return NotFound("File not found");
}
byte[] fileBytes = await System.IO.File.ReadAllBytesAsync(localFilePath);

if (string.IsNullOrEmpty(logFilePath) || !System.IO.File.Exists(logFilePath))
return File(fileBytes, "application/octet-stream", Path.GetFileName(localFilePath));
}
catch (Exception)
{
return NotFound("File not found");
return NotFound();
}
byte[] fileBytes = await System.IO.File.ReadAllBytesAsync(logFilePath);

return File(fileBytes, "application/octet-stream", Path.GetFileName(logFilePath));
}

}

}

0 comments on commit bb4e4bf

Please sign in to comment.