3 weeks ago
Hi community,
we are in the progress of migrating our CAP7 application to CAP8. In our app we have a function to download an asset from the BTP object store defined like this:
this.on(download, async (req: Request) => {
const fileBuffer = await this.objectStoreService.read(
`assets/${req.data.assetId}`,
);
req.http?.res.setHeader('Content-Type', asset.mediaType!);
req.http?.res.setHeader(
'Content-Disposition',
`inline;filename=${asset.fileName}`,
);
req.http?.res.send(fileBuffer);
});
In CAP7 this code worked fine, but now it's giving the following error:
[cds] - Error: Cannot set headers after they are sent to the client
Actually, even the following simple code will now give the error above.
this.on(download, async (req: Request) => {
req.http?.res.send('OK');
}
Any recommendations on how to implement a file download with CAP8 now?
Thanks
User | Count |
---|---|
70 | |
10 | |
10 | |
10 | |
10 | |
8 | |
8 | |
7 | |
5 | |
5 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.