Describe the bug
Annotating an inline attachment with @Core.AcceptableMediaTypes leads to the file upload to fail.
(local development using cds watch)
To Reproduce
Steps to reproduce the behavior:
- Create an entity with an inline attachment.
using {cuid} from '@sap/cds/common';
using {Attachment, Attachments} from '@cap-js/attachments';
namespace sample
entity Invoices : cuid {
documentNumber : String;
// annotation causes file upload to fail
attachment : Attachment;
// Required trigger UI enhancement for attachments due to a different bug.
attachments : Composition of many Attachments;
}
annotate Invoices with @(
UI.LineItem: [ {Value: attachment_filename}],
UI.Facets : [] // Required for plugin to add facets
)
(Note: the attachments composition is only required to add the facet for the inline attachment. see: #470)
- Expose the entity through a service definition and apply annotation
service AccountinService {
@odata.draft.enabled
entity Invoices as projection on my.Invoices;
}
annotate AccounetingServie.Invoices with {
attachment @Core.AcceptableMediatypes: ['application/pdf']
}
- Start development preview with
cds watch
- Open Fiori preview for
AccountingService.Invoices
- Create a new entity to open the object page
- Select a file to upload for the inline attachment
- The upload fails with an on screen error message
"The file upload failed".
Logs:
[odata] - PUT /odata/v4/accountin/Invoices(ID=9f9c3291-eccf-40ed-80ac-e9d9c043c3d4,IsActiveEntity=false)/attachment_content
[cds] - ❗️Uncaught TypeError: Cannot read properties of undefined (reading 'split')
at checkMimeTypeMatch (.../sample/node_modules/@cap-js/attachments/lib/helper.js:415:33)
at validateAttachmentMimeType (.../sample/node_modules/@cap-js/attachments/lib/generic-handlers.js:574:8)
at ApplicationService.putUpdateInlineAttachments (.../sample/node_modules/@cap-js/attachments/lib/plugin.js:601:14)
at next (.../sample/node_modules/@sap/cds/lib/srv/srv-dispatch.js:57:36)
at ApplicationService.handle (.../sample/node_modules/@sap/cds/lib/srv/srv-dispatch.js:60:6)
at process.processTicksAndRejections (node:internal/process/task_queues:104:5)
at async ApplicationService.draftHandle [as handle] (.../sample/node_modules/@sap/cds/libx/_runtime/fiori/lean-draft.js:1127:7)
[cds] - ❗️server shutdown ...❗️
Expected behavior
When using @Core.AcceptableMediaTypes with an inline attachment, the upload should not fail.
Screenshots
On screen failure message after submiting a document to upload:

Customer Info
Company: TUM project with SAP.
Describe the bug
Annotating an inline attachment with
@Core.AcceptableMediaTypesleads to the file upload to fail.(local development using
cds watch)To Reproduce
Steps to reproduce the behavior:
(Note: the
attachmentscomposition is only required to add the facet for the inline attachment. see: #470)cds watchAccountingService.Invoices"The file upload failed".Logs:
Expected behavior
When using
@Core.AcceptableMediaTypeswith an inline attachment, the upload should not fail.Screenshots
On screen failure message after submiting a document to upload:

Customer Info
Company: TUM project with SAP.