4 weeks ago
Hi Team,
I have been trying to download a image file as an attachment in CAP Java project . I have been able to do so by going through the link https://cap.cloud.sap/docs/guides/providing-services#serving-media-data using Odata V4. But when I try to do the same by using OData V2 (after migrating the same project by going through the link https://cap.cloud.sap/docs/java/migration#v2adapter) , its not downloading as a attachment but its just giving the binary stream as response. Have anybody experienced such issue in CAP Java using Odata V2?
Content In DB CDS
====================
@cds.persistence.skip
entity Books {
image : LargeBinary @Core.MediaType: 'image/png' @Core.ContentDisposition.Filename:fileName ;
key fileName : String;
}
Content in SRV CDS
===================
@readonly entity BookSet as projection on db.Books;
Content in handler
==================
@On(event = CqnService.EVENT_READ,entity = BookSet_.CDS_NAME)
public BookSet getBookSet(EventContext context) throws FileNotFoundException,IOException {
BookSet bookSet = BookSet.create();
File imageFile = new File("src/main/resources/smile.png");
bookSet.setImage(new FileInputStream(imageFile));
bookSet.setFileName("smiley.png");
return bookSet;
}
Request clarification before answering.
User | Count |
---|---|
86 | |
11 | |
9 | |
8 | |
6 | |
6 | |
5 | |
5 | |
5 | |
5 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.