Feat/support custom file extensions instead of mime types for file records#819
Conversation
add fileExtension option to os.recordFile() API and record file actions allow file uploads with fileExtension when MIME type is unavailable wire fileExtension through AuxLibrary.ts, RecordsManager.ts, and records server/controller make fileMimeType optional for record-file requests when fileExtension is provided
…omputed MIME type
There was a problem hiding this comment.
Pull request overview
Adds support for specifying a custom file extension when recording file records, enabling uploads for formats without well-known MIME types (fixes #799).
Changes:
- Extends the client/runtime record-file APIs to accept
fileExtensionand propagate it through to the records server. - Updates records server validation and file-record handling to allow
fileMimeTypeto be optional whenfileExtensionis provided (and validate mismatches when both are provided). - Adds/updates tests and snapshots for the new request shape and behavior, plus a changelog entry.
Reviewed changes
Copilot reviewed 10 out of 10 changed files in this pull request and generated 7 comments.
Show a summary per file
| File | Description |
|---|---|
| src/aux-vm/managers/RecordsManager.ts | Sends fileExtension to the records API and conditionally omits fileMimeType when only an extension is provided. |
| src/aux-runtime/runtime/RecordsEvents.ts | Adds fileExtension to RecordFileAction and updates the recordFile() action creator signature. |
| src/aux-runtime/runtime/AuxLibrary.ts | Extends os.recordFile() options to include fileExtension and forwards it into the action. |
| src/aux-records/snapshots/RecordsServer.spec.ts.snap | Updates API schema snapshots to reflect optional fileMimeType and new fileExtension. |
| src/aux-records/Validations.ts | Updates request schema to allow optional fileMimeType and adds fileExtension. |
| src/aux-records/RecordsServer.tsx | Allows requests that specify either fileMimeType or fileExtension and forwards fileExtension into the file controller. |
| src/aux-records/RecordsServer.spec.ts | Adds coverage for extension-only requests and mismatch validation. |
| src/aux-records/FileRecordsController.ts | Implements extension-based filename generation, mismatch validation, and defaults MIME type for presigned uploads. |
| src/aux-records/FileRecordsController.spec.ts | Adds tests for extension-based filename generation and mismatch validation. |
| CHANGELOG.md | Documents the new feature. |
| const presignResult = await this._store.presignFileUpload({ | ||
| recordName, | ||
| fileName: fileName, | ||
| fileSha256Hex: request.fileSha256Hex, | ||
| fileMimeType: request.fileMimeType, | ||
| fileMimeType: | ||
| request.fileMimeType ?? 'application/octet-stream', | ||
| fileByteLength: request.fileByteLength, |
There was a problem hiding this comment.
When fileExtension is used without fileMimeType, request.fileMimeType is undefined until the presign call (where it defaults to application/octet-stream). This means any allowedMimeTypes policy checks earlier in this method will always fail for extension-only uploads. Consider computing an effectiveMimeType (defaulting to application/octet-stream) once and using it consistently for both policy enforcement and the presign request.
|
@TroyceGowdy Can you go through the Copilot suggestions and apply/resolve them? |
…ad_of_mime_types_for_file_records
fixes #799