...
Create a new attachment category in Aptify Smart Client (under Framework), name it as DOB, and scope it to Entity. Add Persons under Entities tab. Once DOB attachment category is created, we will need 3 JSON endpoints.
Here we can see the DOB category under persons attachment. We added one DOB attachment to it as given in below screenshot. Now, we will View and Download this attachment using our JSON endpoints.
Anchorb b
JSON Endpoints
b | |
b |
...
Here is the response as shown in POSTMAN:
Anchor | ||||
---|---|---|---|---|
|
...
Download the DOB attachment of the above person in Chrome browser. As we can see in the Screenshot below, we successfully downloaded the attachment which we uploaded initially through Smart Client.
The code given below provides security to this endpoint. We will discuss about this in Security.
...
This endpoint uses the "Test Attachment PF” process flow which is under HDEB-10 (Code + Metadata) Attachments.zip → HDEB-10_PF_TestAttachment.cmpack.
Info | ||
---|---|---|
| ||
For the POC, Entity Name, and Category Id are hardcoded in the Business Logic. |
...
Upload one more DOB attachment to the person as shown is the below screenshot, using this endpoint:
Now, refresh the Person record on Smart Client and we can see that there are two attachments. Second attachment uploaded by using JSON endpoint.
Also, when we hit 'ViewAttachments' endpoint, we can see two attachments being returned.
Anchorc c
Security
c | |
c |
...
Whenever an unauthorized person tries to fetch an attachment, this give errors as given below:
Deployment Instructions
...
- Extract the files from HDEB-10 (Code + Metadata) Attachments.zip.
- Unpack the PF's and DBO's CMPacks using CM tool.
- Paste FileUpload.json and DownloadAttachment.json files under “..\eBusiness\json\metadata\v1\Endpoints\ProfilePersons” folder.
4. The above three endpoints are registered under HDEB-10 (Code + Metadata) Attachments.zip → ProfilePersonEndpoint.json file.
Code Block | ||||||
---|---|---|---|---|---|---|
| ||||||
"UploadFile": { "$ref": "FileUpload.json#/UploadFile" }, "ViewAllAttachments": { "$ref": "DownloadAttachment.json#/ViewAllAttachments" }, "DownloadAttachment": { "$ref": "DownloadAttachment.json#/getSingleDownload" } |
5. Add the class 'AttachmentComponent.cs' from HDEB-10 (Code + Metadata) Attachments.zip under 'MultipartFormDataProcessFlows' project in Visual Studio.
This class Implements “IProcessComponent” interface. This component is responsible for attaching the Attachment to the entity record specified by the Input Parameters.