Skip to content

Next Gen STEP AP242 Native-ish BREP Geometric Modeling Kernel

Raise and align STEP upload limit to 250 MB

Yuechen Li67dc448fb5de
diff --git a/Aetheris.Server/Configuration/StepUploadOptions.cs b/Aetheris.Server/Configuration/StepUploadOptions.cs
new file mode 100644
index 00000000..81c9dd77
--- /dev/null
+++ b/Aetheris.Server/Configuration/StepUploadOptions.cs
@@ -0,0 +1,10 @@
+namespace Aetheris.Server.Configuration;
+
+public sealed class StepUploadOptions
+{
+ public const string SectionName = "StepUpload";
+
+ public int MaxUploadSizeMb { get; init; } = 250;
+
+ public long MaxUploadSizeBytes => MaxUploadSizeMb * 1024L * 1024L;
+}
diff --git a/Aetheris.Server/Program.cs b/Aetheris.Server/Program.cs
index a366ed74..340be2e3 100644
--- a/Aetheris.Server/Program.cs
+++ b/Aetheris.Server/Program.cs
@@ -1,8 +1,20 @@
using Aetheris.Server.Api;
+using Aetheris.Server.Configuration;
using Aetheris.Server.Documents;
var builder = WebApplication.CreateBuilder(args);
+var stepUploadOptions = builder.Configuration
+ .GetSection(StepUploadOptions.SectionName)
+ .Get<StepUploadOptions>()
+ ?? new StepUploadOptions();
+
+builder.WebHost.ConfigureKestrel(options =>
+{
+ options.Limits.MaxRequestBodySize = stepUploadOptions.MaxUploadSizeBytes;
+});
+
+builder.Services.AddSingleton(stepUploadOptions);
builder.Services.AddEndpointsApiExplorer();
builder.Services.AddSwaggerGen();
builder.Services.AddSingleton<KernelDocumentStore>();
diff --git a/Aetheris.Server/appsettings.Development.json b/Aetheris.Server/appsettings.Development.json
index 0c208ae9..fb8802cf 100644
--- a/Aetheris.Server/appsettings.Development.json
+++ b/Aetheris.Server/appsettings.Development.json
@@ -4,5 +4,8 @@
"Default": "Information",
"Microsoft.AspNetCore": "Warning"
}
+ },
+ "StepUpload": {
+ "MaxUploadSizeMb": 250
}
}
diff --git a/Aetheris.Server/appsettings.json b/Aetheris.Server/appsettings.json
index 10f68b8c..4a535da5 100644
--- a/Aetheris.Server/appsettings.json
+++ b/Aetheris.Server/appsettings.json
@@ -5,5 +5,8 @@
"Microsoft.AspNetCore": "Warning"
}
},
- "AllowedHosts": "*"
+ "AllowedHosts": "*",
+ "StepUpload": {
+ "MaxUploadSizeMb": 250
+ }
}
diff --git a/aetheris.client/src/App.tsx b/aetheris.client/src/App.tsx
index acba8b0d..35899b3d 100644
--- a/aetheris.client/src/App.tsx
+++ b/aetheris.client/src/App.tsx
@@ -21,6 +21,7 @@ import { StepImportDropzone } from './components/StepImportDropzone';
import { Button } from './components/ui/button';
import { ViewerViewport } from './viewer/ViewerViewport';
import { mapTessellationToRenderData } from './viewer/tessellationMapper';
+import { STEP_UPLOAD_LIMIT_BYTES, STEP_UPLOAD_LIMIT_MB, formatMegabytes } from './config/stepUpload';
type RequestStatus = 'idle' | 'loading' | 'success' | 'error';
type BooleanOperationUi = 'Union' | 'Subtract' | 'Intersect';
@@ -73,8 +74,6 @@ function App() {
const [isGridVisible, setIsGridVisible] = useState(true);
const [isCoordVisible, setIsCoordVisible] = useState(true);
- const maxStepFileSizeBytes = 5 * 1024 * 1024;
-
const resetSessionState = useCallback(() => {
setBodyIds([]);
setActiveBodyId(null);
@@ -333,12 +332,13 @@ function App() {
return;
}
- if (stepImportFile.size > maxStepFileSizeBytes) {
+ if (stepImportFile.size > STEP_UPLOAD_LIMIT_BYTES) {
+ const limitMessage = `Selected STEP file is too large (${formatMegabytes(stepImportFile.size)}). Limit is ${STEP_UPLOAD_LIMIT_MB} MB.`;
setStatus('error');
- setStatusMessage(`Selected STEP file is too large (${stepImportFile.size} bytes). Limit is ${maxStepFileSizeBytes} bytes.`);
+ setStatusMessage(limitMessage);
setDiagnostics([]);
setImportStatus('error');
- setImportStatusMessage(`Import error: Selected STEP file is too large (${stepImportFile.size} bytes).`);
+ setImportStatusMessage(`Import error: ${limitMessage}`);
return;
}
@@ -369,7 +369,7 @@ function App() {
} finally {
setIsImporting(false);
}
- }, [documentId, documentStatus, maxStepFileSizeBytes, refreshSummaryAndActiveTessellation, runAction, serverStatus, stepImportFile]);
+ }, [documentId, documentStatus, refreshSummaryAndActiveTessellation, runAction, serverStatus, stepImportFile]);
const handleStepFileAccepted = useCallback((selected: File) => {
setStepImportFile(selected);
diff --git a/aetheris.client/src/__tests__/App.test.tsx b/aetheris.client/src/__tests__/App.test.tsx
index 9b07c7ea..c212f4a0 100644
--- a/aetheris.client/src/__tests__/App.test.tsx
+++ b/aetheris.client/src/__tests__/App.test.tsx
@@ -2,6 +2,7 @@ import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest';
import { cleanup, fireEvent, render, screen, waitFor } from '@testing-library/react';
import App from '../App';
import { ApiError } from '../api/aetherisApi';
+import { STEP_UPLOAD_LIMIT_BYTES } from '../config/stepUpload';
const apiMocks = vi.hoisted(() => ({
createDocument: vi.fn(),
@@ -153,6 +154,35 @@ describe('App STEP file upload flow', () => {
expect((screen.getByRole('button', { name: 'Import STEP 242' }) as HTMLButtonElement).disabled).toBe(true);
});
+
+ it('accepts STEP files above the previous 5 MB threshold when under the configured limit', async () => {
+ render(<App />);
+ await screen.findByText('Document: Ready');
+
+ const fileInput = screen.getByTestId('step-import-file-input') as HTMLInputElement;
+ const file = new File(['ISO-10303-21;'], 'stc_09_like.stp', { type: 'text/plain' });
+ Object.defineProperty(file, 'size', { value: 6 * 1024 * 1024 });
+
+ fireEvent.change(fileInput, { target: { files: [file] } });
+
+ await screen.findByText('stc_09_like.stp');
+ expect(screen.queryByText('File selection needs attention')).toBeNull();
+ });
+
+ it('rejects STEP files above the configured limit with explicit size details', async () => {
+ render(<App />);
+ await screen.findByText('Document: Ready');
+
+ const fileInput = screen.getByTestId('step-import-file-input') as HTMLInputElement;
+ const file = new File(['ISO-10303-21;'], 'too-large.step', { type: 'text/plain' });
+ Object.defineProperty(file, 'size', { value: STEP_UPLOAD_LIMIT_BYTES + 1024 });
+
+ fireEvent.change(fileInput, { target: { files: [file] } });
+
+ await screen.findByText('File selection needs attention');
+ await screen.findByText(/Selected STEP file is too large \(250\.00 MB\)\. Limit is 250 MB\./i);
+ });
+
it('accepts drag-and-drop STEP files', async () => {
render(<App />);
await screen.findByText('Document: Ready');
diff --git a/aetheris.client/src/components/StepImportDropzone.tsx b/aetheris.client/src/components/StepImportDropzone.tsx
index 16d77ce4..56066826 100644
--- a/aetheris.client/src/components/StepImportDropzone.tsx
+++ b/aetheris.client/src/components/StepImportDropzone.tsx
@@ -1,5 +1,6 @@
import { useCallback, useEffect, useMemo, useRef, useState, type DragEvent } from 'react';
import { z } from 'zod';
+import { STEP_UPLOAD_LIMIT_BYTES, STEP_UPLOAD_LIMIT_MB, formatMegabytes } from '../config/stepUpload';
type StepSchemaFamily = 'AP203' | 'AP214' | 'AP242' | 'Unknown';
type StepCompatibility = 'Supported' | 'Experimental' | 'Not verified';
@@ -48,6 +49,13 @@ const stepFileSelectionSchema = z
message: 'File is empty.',
});
}
+
+ if (file.size > STEP_UPLOAD_LIMIT_BYTES) {
+ ctx.addIssue({
+ code: z.ZodIssueCode.custom,
+ message: `Selected STEP file is too large (${formatMegabytes(file.size)}). Limit is ${STEP_UPLOAD_LIMIT_MB} MB.`,
+ });
+ }
});
function fileListToArray(fileList: FileList | null): File[] {
diff --git a/aetheris.client/src/config/stepUpload.ts b/aetheris.client/src/config/stepUpload.ts
new file mode 100644
index 00000000..8875a42a
--- /dev/null
+++ b/aetheris.client/src/config/stepUpload.ts
@@ -0,0 +1,6 @@
+export const STEP_UPLOAD_LIMIT_MB = 250;
+export const STEP_UPLOAD_LIMIT_BYTES = STEP_UPLOAD_LIMIT_MB * 1024 * 1024;
+
+export function formatMegabytes(bytes: number): string {
+ return `${(bytes / (1024 * 1024)).toFixed(2)} MB`;
+}