We can then get the image back with the following request: GET: Pretty simple, right? However using the default handlers means that the files are stored in the database which is often not a good idea. Thanks Uwe Fetzer for pointing this out.Īnd then a second request to upload the image (using the id returned by the first request): PUT: Request Headers: Note: the request body is an empty object in this case because the ID is generated by the framework (type UUID) and we only have one mandatory property (we still need to send some application/json payload for some reason). Then we can create a simple service (srv\media-service.cds): using media as db from './db/schema' Įntity Pictures as projection on db.Pictures Īs we are using OData v4, we can store an image by sending one request to create the object: POST: Request Headers: Working with media resources (i.e files) is well covered in the CAP documentation so let’s jump into a very simple example.įirst we need to create a new CAP project (Node.js OData v4) and a cds file to define our data model (db\schema.cds): namespace media
0 Comments
Leave a Reply. |