search and ai stabilization work, localization stablized.
This commit is contained in:
@@ -4,6 +4,8 @@
|
||||
// Task: AS-005 - Create artifact submission endpoint
|
||||
// Description: Content fetch helpers for artifact submissions
|
||||
// -----------------------------------------------------------------------------
|
||||
using static StellaOps.Localization.T;
|
||||
|
||||
namespace StellaOps.Artifact.Api;
|
||||
|
||||
public sealed partial class ArtifactController
|
||||
@@ -18,7 +20,7 @@ public sealed partial class ArtifactController
|
||||
|
||||
if (!Uri.TryCreate(uri, UriKind.Absolute, out var parsedUri))
|
||||
{
|
||||
throw new ArgumentException($"Invalid URI format: {uri}");
|
||||
throw new ArgumentException(_t("common.artifact.uri_format_invalid", uri));
|
||||
}
|
||||
|
||||
return parsedUri.Scheme.ToLowerInvariant() switch
|
||||
@@ -26,7 +28,7 @@ public sealed partial class ArtifactController
|
||||
"s3" => await FetchFromS3Async(parsedUri, ct).ConfigureAwait(false),
|
||||
"http" or "https" => await FetchFromHttpAsync(parsedUri, ct).ConfigureAwait(false),
|
||||
"file" => await FetchFromFileAsync(parsedUri, ct).ConfigureAwait(false),
|
||||
_ => throw new NotSupportedException($"URI scheme not supported: {parsedUri.Scheme}")
|
||||
_ => throw new NotSupportedException(_t("common.artifact.uri_scheme_not_supported", parsedUri.Scheme))
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,6 +5,7 @@
|
||||
// Description: File fetch for artifact submissions
|
||||
// -----------------------------------------------------------------------------
|
||||
using Microsoft.Extensions.Logging;
|
||||
using static StellaOps.Localization.T;
|
||||
|
||||
namespace StellaOps.Artifact.Api;
|
||||
|
||||
@@ -18,14 +19,14 @@ public sealed partial class ArtifactController
|
||||
|
||||
if (!System.IO.File.Exists(filePath))
|
||||
{
|
||||
throw new FileNotFoundException($"File not accessible: {filePath}");
|
||||
throw new FileNotFoundException(_t("common.artifact.file_not_accessible", filePath));
|
||||
}
|
||||
|
||||
var fileInfo = new FileInfo(filePath);
|
||||
if (fileInfo.Length > 100 * 1024 * 1024)
|
||||
{
|
||||
throw new InvalidOperationException(
|
||||
$"File too large: {fileInfo.Length} bytes exceeds 100MB limit");
|
||||
_t("common.artifact.file_too_large", fileInfo.Length));
|
||||
}
|
||||
|
||||
return await System.IO.File.ReadAllBytesAsync(filePath, ct).ConfigureAwait(false);
|
||||
|
||||
@@ -6,6 +6,7 @@
|
||||
// -----------------------------------------------------------------------------
|
||||
using Microsoft.Extensions.Logging;
|
||||
using System.Net.Http;
|
||||
using static StellaOps.Localization.T;
|
||||
|
||||
namespace StellaOps.Artifact.Api;
|
||||
|
||||
@@ -26,21 +27,21 @@ public sealed partial class ArtifactController
|
||||
if (!headResponse.IsSuccessStatusCode)
|
||||
{
|
||||
throw new InvalidOperationException(
|
||||
$"URI not accessible: {uri} returned {headResponse.StatusCode}");
|
||||
_t("common.artifact.uri_not_accessible", uri, headResponse.StatusCode));
|
||||
}
|
||||
|
||||
var contentLength = headResponse.Content.Headers.ContentLength;
|
||||
if (contentLength > 100 * 1024 * 1024)
|
||||
{
|
||||
throw new InvalidOperationException(
|
||||
$"Content too large: {contentLength} bytes exceeds 100MB limit");
|
||||
_t("common.artifact.content_too_large", contentLength));
|
||||
}
|
||||
|
||||
return await httpClient.GetByteArrayAsync(uri, ct).ConfigureAwait(false);
|
||||
}
|
||||
catch (HttpRequestException ex)
|
||||
{
|
||||
throw new InvalidOperationException($"Failed to fetch from {uri}: {ex.Message}", ex);
|
||||
throw new InvalidOperationException(_t("common.artifact.fetch_failed", uri, ex.Message), ex);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -17,5 +17,6 @@
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\..\Concelier\__Libraries\StellaOps.Concelier.SbomIntegration\StellaOps.Concelier.SbomIntegration.csproj" />
|
||||
<ProjectReference Include="..\StellaOps.Localization\StellaOps.Localization.csproj" />
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
|
||||
Reference in New Issue
Block a user