You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
this.on("READ", Books, async (req, next) => {
const url = req._.req.path
if (url.includes('image')) {
let file = fs.readFileSync(path.resolve(__dirname, '../image.png'));
const readable = new Readable()
const result = new Array()
readable.push(file)
readable.push(null)
result.push({
value: readable,
$mediaContentType: "image/png",
$mediaContentDispositionFilename: "image.png"
})
return result
} else
await next();
})
But if I use same method in unbound action, response is not a file, it's json with following content. ( After renaming .png to txt) {"@odata.context":"$metadata#CatalogService.return_CatalogService_downloadAllImages"}
Unbound action definition
function downloadAllImages() returns {
@Core.ContentDisposition.Filename: fileName
@Core.MediaType : mediaType
value : LargeBinary;
mediaType : String;
fileName : String;
};
Handler of unbound action.
this.on('downloadAllImages', async (req) => {
let file = fs.readFileSync(path.resolve(__dirname, '../image.png'));
const readable = new Readable()
const result = new Array()
readable.push(file)
readable.push(null)
result.push({
value: readable,
$mediaContentType: "image/png",
$mediaContentDispositionFilename: "image.png"
})
return result
})
How can I send file response to client in unbound action ?
Regards.
The text was updated successfully, but these errors were encountered:
Hi @ilhanburak ,
in this repository we handle issue related to documentation. I don't see any reference in your issue where exisiting documentation is linked which might be wrong, insufficient or else.
Overall my impression is, that you would get faster and better support when asking this question in the SAP Community.
Do you agree?
Hello,
If I add custom handler to Read entity with mediatype property, i can return binary result to client.
And implementation of read event.
But if I use same method in unbound action, response is not a file, it's json with following content. ( After renaming .png to txt)
{"@odata.context":"$metadata#CatalogService.return_CatalogService_downloadAllImages"}
Unbound action definition
Handler of unbound action.
How can I send file response to client in unbound action ?
Regards.
The text was updated successfully, but these errors were encountered: