

Then add a dependency in the srv\package.json file for the AWS SDK. Then update the mta.yaml file to add a new resource and dependency: modules: Or you can also run it locally thanks to Gregor Wolf contribution.įirst let’s create a service instance of the objectstore service: > cf create-service objectstore s3-standard s3-pictures You’ll need an SCP subaccount on Cloud Foundry (AWS) for this. SAP Cloud Platform provides an ObjectStore service so let’s see how we can leverage it. We can for instance store the files in Amazon S3. 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
