Skip to content

[Version: 3.12.1] Cannot query Attachments content programatically when using SAP Object Store #447

Description

@fidsusj

Describe the bug
In my CAP app, I would like to query the content of an attachment programatically as described here. The documentation says:

Note that the binary content field is excluded by default, making the operation lightweight

I try to explicitly return the content of the Attachment via a query like this:

await SELECT.one.from('ExampleEntity.data').columns('content').where({ up__ID: exampleEntity.ID })

This works locally using @cap-js/sqlite, however when deployed and using SAP HANA Cloud + SAP Object Store, the above query always returns null for content as observed when debugging remotely on Kubernetes.

Also when querying via OData like

GET {{baseUrl}}/ExampleEntity({{exampleEntityId}})/data({{dataId}})/content

the content is returned as expected, so it should be populated in the SAP Object Store.

Use Case: I would like provide a download OData action that zips multiple attachments / files together and returns them as a compressed archive instead.

To Reproduce
In the schema.cds:

entity ExampleEntity : cuid, managed {
  data          : Composition of one Attachments;
}

In some service file:

const exampleEntity = await SELECT.one.from('ExampleEntity').where({ ID: '...' })

 // returns { "content": null }
const notWorking = await SELECT.one.from('ExampleEntity.data').columns('content').where({ up__ID: exampleEntity.ID })

// returns { "filename": "...", "mimeType": "..."}
const working = await SELECT.one.from('ExampleEntity.data').where({ up__ID: exampleEntity.ID }) 

Expected behavior
I expect content to be returned as Stream.Readable or Buffer instead of being null.

Since this is an initial implementation, I am not aware if this ever worked in the past. So maybe this is not even a bug but an unsupported feature.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions