Giter VIP home page Giter VIP logo

nils / attachments Goto Github PK

View Code? Open in Web Editor NEW

This project forked from cap-js/attachments

0.0 0.0 0.0 42.12 MB

The @cap-js/attachments package is a CDS plugin that provides out-of-the box asset storage and handling by using an aspect Attachments. It also provides a CAP-level, easy to use integration of the SAP Object Store.

License: Apache License 2.0

JavaScript 93.92% CAP CDS 6.08%

attachments's Introduction

REUSE status

Attachments Plugin

The @cap-js/attachments package is a CDS plugin that provides out-of-the box asset storage and handling by using an aspect Attachments. It also provides a CAP-level, easy to use integration of the SAP Object Store.

Table of Contents

Setup

To enable attachments, simply add this self-configuring plugin package to your project:

 npm add @cap-js/attachments

In this guide, we use the Incidents Management reference sample app as the base application, to add Attachments type to the CDS model.

Note

To be able to use the Fiori uploadTable feature, you must ensure ^1.121.0 SAPUI5 version is updated in the application's index.html

Use Attachments

To use Attachments, simply add an element referring to the pre-defined Attachments type as follows:

using { Attachments } from '@cap-js/attachments';

entity Incidents {
  // ...
  attachments: Composition of many Attachments;
}

Test-drive Locally

With the steps above, we have successfully set up asset handling for our reference application. Let's see that in action. We can try out the scenarios where the attachments contents are stored locally in the database.

  1. Start the server:
  • Default scenario (In memory database):
    cds watch
  1. Navigate to the object page of the incident Solar panel broken:

    Go to Object page for incident Solar panel broken

  2. The Attachments type has generated an out-of-the-box Attachments table (see 1) at the bottom of the Object page:

Attachments Table

  1. 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 xmpl/db/content/Solar Panel Report.pdf:

Upload an attachment

  1. Delete a file by going into Edit mode and selecting the file(s) and by using the Delete button on the Attachments table. Then click the Save button to have that file deleted from the resource (database, S3 bucket, etc.). We demonstrate this by deleting the previously uploaded PDF file: Solar Panel Report.pdf

Delete an attachment

Using SAP Object Store

For using SAP Object Store, you must already have a SAP Object Store service instance with a bucket which you can access. To connect it, follow this setup.

  1. Log in to Cloud Foundry:

    cf login -a <CF-API> -o <ORG-NAME> -s <SPACE-NAME>
  2. To bind to the service continue with the steps below.

    In the project directory, you can generate a new file _.cdsrc-private.json by running:

    cds bind objectstore -2 <INSTANCE>:<SERVICE-KEY> --kind s3

Using SAP Malware Scanning Service

For using SAP Malware Scanning Service, you must already have a service instance which you can access.

  1. To bind to the service continue with the steps below.

    cds bind malware-scanner -2 <INSTANCE>:<SERVICE-KEY>

By default, malware scanning is enabled for all profiles except development profile. You can configure malware scanning by setting:

"attachments": {
    "scan": true
}

Contributing

This project is open to feature requests/suggestions, bug reports etc. via GitHub issues. Contribution and feedback are encouraged and always welcome. For more information about how to contribute, the project structure, as well as additional contribution information, see our Contribution Guidelines.

Code of Conduct

We as members, contributors, and leaders pledge to make participation in our community a harassment-free experience for everyone. By participating in this project, you agree to abide by its Code of Conduct at all times.

Licensing

Copyright 2024 SAP SE or an SAP affiliate company and contributors. Please see our LICENSE for copyright and license information. Detailed information including third-party components and their licensing/copyright information is available via the REUSE tool.

attachments's People

Contributors

muskansethi1 avatar mnkiefer avatar danjoa avatar ramindia avatar sidakphull avatar jeevitha011 avatar danschlachter avatar nils avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.