Skip to content

Commit 91e3aeb

Browse files
committed
Fix formatting and indentation in README.md for better readability
1 parent b15d165 commit 91e3aeb

File tree

1 file changed

+74
-67
lines changed

1 file changed

+74
-67
lines changed

README.md

Lines changed: 74 additions & 67 deletions
Original file line numberDiff line numberDiff line change
@@ -33,80 +33,83 @@ The `@cap-js/attachments` package is a [CDS plugin](https://cap.cloud.sap/docs/n
3333

3434
For a quick local development setup with in-memory storage:
3535

36-
- The plugin is self-configuring as described in [Package Setup](#package-setup). To enable attachments, simply add the plugin package to your project:
37-
```sh
38-
npm add @cap-js/attachments
39-
```
40-
41-
<details>
42-
43-
The attachments plugin needs to be referenced in the package.json of the consuming CAP NodeJS application:
44-
45-
```cds
46-
"devDependencies": {
47-
"@cap-js/attachments": "<latest-version>",
48-
//...
49-
}
50-
```
51-
52-
In addition, different profiles can be found in `package.json` as well, such as:
36+
- The plugin is self-configuring as described, see the following details section. To enable attachments, simply add the plugin package to your project:
37+
```sh
38+
npm add @cap-js/attachments
39+
```
40+
41+
<details>
42+
The attachments plugin needs to be referenced in the package.json of the consuming CAP NodeJS application:
43+
44+
```cds
45+
"devDependencies": {
46+
"@cap-js/attachments": "<latest-version>",
47+
// (...)
48+
}
49+
```
5350
54-
```json
55-
"cds": {
56-
"requires": {
57-
//...
58-
"[hybrid]": {
59-
"attachments": {
60-
"kind": "s3"
61-
//...
51+
In addition, different profiles can be found in `package.json` as well, such as:
52+
53+
```json
54+
"cds": {
55+
"requires": {
56+
// (...)
57+
"[hybrid]": {
58+
"attachments": {
59+
"kind": "s3"
60+
// (...)
61+
}
62+
}
6263
}
6364
}
64-
}
65-
}
66-
```
67-
</details>
65+
```
66+
</details>
6867
6968
- To use Attachments, extend a CDS model by adding an element that refers to the pre-defined Attachments type (see [Changes in the CDS Models](#changes-in-the-cds-models) for more details):
70-
```cds
71-
using { Attachments } from '@cap-js/attachments';
7269
73-
entity Incidents {
74-
// ...
75-
attachments: Composition of many Attachments;
76-
}
77-
```
70+
```cds
71+
using { Attachments } from '@cap-js/attachments';
72+
73+
entity Incidents {
74+
// (...)
75+
attachments: Composition of many Attachments;
76+
}
77+
```
7878

7979
In this guide, we use the [Incidents Management reference sample app](https://github.com/cap-js/incidents-app) as the base application to provide a demonstration how to use this plugin. A miniature version of this app can be found within the [tests](./tests/incidents-app) directory for local testing.
8080

8181
For productive use, a valid object store binding is required, see [Object Stores](#object-stores) and [Storage Targets](#storage-targets).
8282

83-
8483
### Local Walk-Through
85-
With the steps above, we have successfully set up asset handling for our reference application. To test the application locally, use the following steps. For local testing, the attachments contents are stored in a local database.
84+
85+
With the steps above, we have successfully set up asset handling for our reference application. To test the application locally, use the following steps.
86+
87+
> [!NOTE]
88+
> For local testing, the attachment objects are stored in a [local database](https://cap.cloud.sap/docs/guides/databases-sqlite).
8689
8790
1. **Start the server**:
8891

89-
- *Default* scenario (In memory database):
90-
```sh
91-
cds watch
92-
```
92+
- *Default* scenario (In memory database):
93+
```sh
94+
cds watch
95+
```
9396

9497
2. **Navigate to the object page** of the incident `Solar panel broken`:
95-
96-
Go to object page for incident **Solar panel broken**
98+
Go to object page for incident **Solar panel broken**
9799

98100
3. The `Attachments` type has generated an out-of-the-box Attachments table (see 1) at the bottom of the Object page:
99-
<img width="1300" alt="Attachments Table" style="border-radius:0.5rem;" src="etc/facet.png">
101+
<img width="1300" alt="Attachments Table" style="border-radius:0.5rem;" src="etc/facet.png">
100102

101103
4. **Upload a file** by going into Edit mode and either using the **Upload** button on the Attachments table or by drag/drop. Then click the **Save** button to have that file stored that file in the dedicated resource (database, S3 bucket, etc.). We demonstrate this by uploading the PDF file from [_tests/integration/content/sample.pdf_](./tests/integration/content/sample.pdf):
102-
<img width="1300" alt="Upload an attachment" style="border-radius:0.5rem;" src="etc/upload.gif">
104+
<img width="1300" alt="Upload an attachment" style="border-radius:0.5rem;" src="etc/upload.gif">
103105

104106
5. **Delete a file** by going into Edit mode, selecting the file, and pressing the **Delete** button above the Attachments table. Clicking the **Save** button will then delete that file from the resource (database, S3 bucket, etc.).
105-
<img width="1300" alt="Delete an attachment" style="border-radius:0.5rem;" src="etc/delete.gif">
107+
<img width="1300" alt="Delete an attachment" style="border-radius:0.5rem;" src="etc/delete.gif">
106108

107109
### Changes in the CDS Models
108110

109111
To use the aspect `Attachments` on an existing entity, the corresponding entity needs to either include attachments as an element in the model definition or be extended in a CDS file in the `srv` module. In the quick start, the former was done, adding an element to the model definition:
112+
110113
```cds
111114
using { Attachments } from '@cap-js/attachments';
112115
@@ -116,7 +119,8 @@ entity Incidents {
116119
}
117120
```
118121

119-
The entity Incidents can also be extended in the `srv` module, as seen in the following example:
122+
The entity Incidents can also be extended in the `srv` module, as seen in the following example:
123+
120124
```cds
121125
using { Attachments } from '@cap-js/attachments';
122126
@@ -142,23 +146,23 @@ When testing locally, the plugin operates without a dedicated storage target, st
142146
Meanwhile, with a dedicated storage target the attachment is not stored in the underlying database; instead, it is saved on the specified storage target and only a reference to the file including metadata is kept in the database, as defined in the CDS model.
143147

144148
For productive use, you need a valid object store binding. Currently, only the AWS S3 object store is supported.
145-
For using an AWS S3 Object Store in BTP, you must already have an SAP Object Store service instance on an AWS landscape created. To bind it locally, follow this setup:
149+
For using an AWS S3 Object Store in BTP, you must already have an SAP Object Store service instance on an AWS landscape created. To bind it in a hybrid setup, follow this setup:
146150

147151
1. Log in to Cloud Foundry:
148152

149-
```sh
150-
cf login -a <CF-API> -o <ORG-NAME> -s <SPACE-NAME> --sso
151-
```
153+
```sh
154+
cf login -a <CF-API> -o <ORG-NAME> -s <SPACE-NAME> --sso
155+
```
152156

153157
2. To bind to the service, generate a new file _.cdsrc-private.json in the project directory by running:
154158

155-
```sh
156-
cds bind <LocalObjectStoreName> --to <RemoteObjectStoreName>
157-
```
159+
```sh
160+
cds bind <HybridObjectStoreName> --to <RemoteObjectStoreName>
161+
```
158162

159-
Where `LocalObjectStoreName` can be any name given by the user here and `RemoteObjectStoreName` is the name of your object store instance in SAP BTP.
163+
Where `HybridObjectStoreName` can be any name given by the user here and `RemoteObjectStoreName` is the name of your object store instance in SAP BTP.
160164

161-
3. To run the application locally, run the command:
165+
3. To run the application in hybrid mode, run the command:
162166

163167
```bash
164168
cds watch --profile hybrid
@@ -171,11 +175,13 @@ See [Object Stores](#object-stores) for further information on SAP Object Store.
171175
The BTP malware scanning service is used in the `AttachmentService` to scan attachments for vulnerabilities.
172176

173177
For using [SAP Malware Scanning Service](https://discovery-center.cloud.sap/serviceCatalog/malware-scanning-service), you must already have a service instance which you can access. To bind it, run the following command:
174-
```sh
175-
cds bind <LocalMalwareScannerName> --to <RemoteMalwareScannerName>
176-
```
178+
179+
```sh
180+
cds bind <HybridMalwareScannerName> --to <RemoteMalwareScannerName>
181+
```
177182

178183
By default, malware scanning is enabled for all profiles if a storage provider has been specified. You can configure malware scanning by setting:
184+
179185
```json
180186
{
181187
"cds": {
@@ -213,8 +219,8 @@ entity Incidents {
213219
attachments: Composition of many Attachments;
214220
}
215221
```
216-
In this example, the `@UI.Hidden` is set to `true`, which means the plugin will be hidden by default. You can also use dynamic expressions which are then added to the facet.
217222

223+
In this example, the `@UI.Hidden` is set to `true`, which means the plugin will be hidden by default. You can also use dynamic expressions which are then added to the facet.
218224

219225
```cds
220226
entity Incidents {
@@ -267,13 +273,13 @@ To configure a shared object store instance, modify both the package.json files
267273

268274
```json
269275
"cds": {
270-
"requires": {
271-
"attachments": {
272-
"objectStore": {
273-
"kind": "shared"
274-
}
275-
}
276+
"requires": {
277+
"attachments": {
278+
"objectStore": {
279+
"kind": "shared"
280+
}
276281
}
282+
}
277283
}
278284
```
279285
To ensure tenant identification when using a shared object store instance, the plugin prefixes attachment URLs with the tenant ID. Be sure the shared object store instance is bound to the `mtx` application module before deployment.
@@ -359,6 +365,7 @@ In addition to the field names, header information (`@UI.HeaderInfo`) are also a
359365
## Monitoring & Logging
360366

361367
To configure logging for the attachments plugin, add the following configuration to the `package.json` of the consuming application:
368+
362369
```json
363370
{
364371
"cds": {

0 commit comments

Comments
 (0)