on 2023 Jul 24 11:03 AM
Im implementing a CAP Server with fetches Images from a external Service.
The cds is
entity ImageResource {
key id : String;
content : LargeBinary @Core.MediaType: 'image/jpeg';
}
I connect to the service using cds.connect.to
const extApi = await cds.connect.to({
kind: "rest",
impl: "srv/external/myApi.js",
credentials: {
url: process.env.SERVER_URL
}
});And in my Rest implementation I fetch the image:
req.query = `GET /api/planogram/resource/image/` + req.query.SELECT.from.ref[0].where[2].val;The problem: the remote service implementation from Capire use Axios to get the data: The only way I found to set the ResponsType to arrayBuffer is:
req._binary = true;I think this is a bug somewhere in cds runtime lib / or the documentation how to set this flag beside using the _binary is missing.
I For the records reading the image and giving it back to odata is straightforward:
const response = await next(req);
const readable = new Readable();
readable.push(response);
readable.push(null);
return [{
value: readable,
$mediaContentType: 'image/jpeg'
}]
Request clarification before answering.
| User | Count |
|---|---|
| 18 | |
| 7 | |
| 6 | |
| 6 | |
| 4 | |
| 4 | |
| 3 | |
| 2 | |
| 2 | |
| 2 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.