Skip to content

Latest commit

 

History

History

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 

README.md

General Info

This artifact uses an Object Store as the storage target instead of the underlying database.

Then, the attachment is not stored in the underlying database; instead, it is saved in the respective Object Store, and only a reference to the file is kept in the database, as defined in the CDS model.

To do this, replace the cds-feature-attachments dependency in the pom.xml with:

<dependency>
    <groupId>com.sap.cds</groupId>
    <artifactId>cds-feature-attachments-oss</artifactId>
    <version>${latest-version}</version>
</dependency>

A valid Object Store service binding is required for this, typically one provisioned through SAP BTP. See Local development and Deployment to Cloud Foundry on how to use this object store service binding.

Local development

For local development, bind to an Object Store service using the cds bind command as described in the CAP documentation for hybrid testing:

cds bind <service-instance-name>

This will create an entry in the .cdsrc-private.json file with the service binding configuration. Then start the application with:

cds bind --exec mvn spring-boot:run

If such a binding is not available, use the underlying database as the storage target instead of an Object Store, so use the dependency cds-feature-attachments (not cds-feature-attachments-oss).

Deployment to Cloud Foundry

The corresponding entry in the mta-file possibly looks like:

_schema-version: '0.1'
ID: consuming-app
version: 1.0.0
description: "App consuming the attachments plugin with an object store"
parameters:
  ...
modules:
  - name: consuming-app-srv
# ------------------------------------------------------------
    type: java
    path: srv
    parameters:
      ...
    properties:
      ...
    build-parameters:
      ...
    requires:
      - name: consuming-app-hdi-container
      - name: consuming-app-uaa
      - name: cf-logging
      - name: **object-store-service**
...
resources:
  ...
  - name: **object-store-service**
    type: org.cloudfoundry.managed-service
    parameters:
      service: objectstore
      service-plan: standard

Tests

The unit tests in this module do not need a binding to the respective object stores, run them with mvn clean install.

The integration tests need a binding to a real object store. Run them with mvn clean install -Pintegration-tests-oss. To set the binding, provide the following environment variables:

  • AWS_S3_BUCKET
  • AWS_S3_REGION
  • AWS_S3_ACCESS_KEY_ID
  • AWS_S3_SECRET_ACCESS_KEY
  • AZURE_CONTAINER_URI
  • AZURE_SAS_TOKEN
  • GS_BUCKET
  • GS_PROJECT_ID
  • GS_BASE_64_ENCODED_PRIVATE_KEY_DATA

Implementation details

This artifact provides custom handlers for events from the AttachmentService.

Supported Storage Backends

  • AWS S3
  • Azure Blob Storage
  • Google Cloud Storage

Multitenancy

The plugin supports multi-tenancy scenarios with shared object store instances.

Shared Object Store Instance

To configure a shared object store instance, set the object store kind to shared:

cds:
  attachments:
    objectStore:
      kind: shared

To ensure tenant isolation when using a shared object store instance, the plugin prefixes object keys with the tenant ID. When a tenant unsubscribes, all objects prefixed with that tenant's ID are automatically cleaned up from the shared bucket.

Separate Object Store Instances

Note

Separate object store instances per tenant are not yet supported. This feature is planned for a future release.