npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@amag-ch/sap_cap_common_objectstore

v2.4.1

Published

NodeJS library to communicate with an objectstore

Downloads

211

Readme

npm version npm downloads

NodeJS library to communicate with an objectstore

Table of Contents

Features

  • Fully integrated in CAP as a Service
  • Support S3 objectstore and local objectstore for development testings
  • Autodeletion if corresponding entity entry is been deleted (Entity which uses File)
  • Autohandling streaming, if content is requested
  • Testfiles possible
  • Lazy deletion of objects and only executed, if transaction is successfull
  • Auto configuration with cds plugin feature

Installing

Using npm:

$ npm install @amag-ch/sap_cap_common_objectstore

Using yarn:

$ yarn add @amag-ch/sap_cap_common_objectstore

Configuration

{
    "cds": {
        "requires": {
            "objectstore": {
                "impl": "@amag-ch/sap_cap_common_objectstore",
                "kind": "objectstore"
            }
        }
    }
}

The name and kind must be named objectstore, otherwise CAP cannot inject the credentials from environment

Variant with local objectstore for development testings

{
    "cds": {
        "requires": {
            "objectstore": {
                "impl": "@amag-ch/sap_cap_common_objectstore",
                "kind": "local-objectstore",
                "[production]": {
                    "kind": "objectstore",
                }
            }
        }
    }
}

The local objectstore is saved in folder ~/.cds-objectstore

Standard configuration (cds-plugin)

{
    "cds": {
        "requires": {
            "objectstore": {
                "impl": "@amag-ch/sap_cap_common_objectstore",
                "kind": "local-objectstore",
                "[production]": {
                    "kind": "objectstore"
                }
            }
        }
    }
}

Implementation

Database Schema

using {amag.common.objectstore.File as File} from '@amag-ch/sap_cap_common_objectstore';

entity MyEntity {
    key ID      : UUID;
        file    : File
}

File is definied as Composition. Means if entry of MyEntity is been deleted, also the connected File would be deleted. File is per default defined as attachment (@Core.ContentDisposition.Type: 'attachment'), but could be overwriten with own annotations.

Service for add or read files

const objectstore = await cds.connect.to('objectstore')

const ID = await objectstore.create('Any File Content', { filename: 'Testfile.txt', contentType: 'text/plain' })

const file = await objectstore.read(ID)

console.log(file.modifiedAt)

const stream = await objectstore.readContent(ID)

Testing

Create a folder (e.g. test/objectstore) with all needed files named by ID, which is also used in test/data/amag.common.objectstore-Files.csv.

With cds-plugin mode this folder is automatically registered.

Otherwise add file test/init.js with following code snippet to register your folder.

module.exports = async () => {
    require('@amag-ch/sap_cap_common_objectstore').testing.register(`${__dirname}/objectstore`)
}

License

MIT