Skip to content

Latest commit

 

History

History
116 lines (88 loc) · 5.19 KB

README.md

File metadata and controls

116 lines (88 loc) · 5.19 KB

Contentstack

Contentstack is a headless CMS with an API-first approach. It is a CMS that developers can use to build powerful cross-platform applications in their favorite languages. Build your application frontend, and Contentstack will take care of the rest. Read More.

Contentstack DataSync Asset Store AWS-S3

Contentstack DataSync lets you sync your Contentstack data with your database, enabling you to save data locally and serve content directly from your database. It is a combination of four powerful modules that is DataSync Webhook Listener, DataSync Manager, DataSync Asset Store - Filesystem and AWS S3, DataSync Content Store — Filesystem, MongoDB and AWS S3.

The Cotentstack AWS S3 Asset Store is part of Contentstack DataSync's content storage drivers and is used to store assets in the AWS S3. Any publish, unpublish, or delete action performed on assets will be tracked by the Webhook Listener and the relevant content will be synced accordingly in your AWS S3.

Along with syncing and storing your assets on Filesystem, you can configure DataSync to sync and store your assets on Amazon S3 server as well.

Please note that this is still work-in-progress and we are working on developing the complete functionality.

Prerequisite

  • Nodejs v8 or above

Usage

This is how the datasync-content-store-filesystem is defined in the boilerplate:

const assetStore = require('@contentstack/datasync-asset-store-aws-s3')   // <<--
const contentStore = require('@contentstack/datasync-content-store-filesystem')
const listener = require('@contentstack/webhook-listener')
const syncManager = require('@contentstack/datasync-manager')
const config = require('./config')

syncManager.setAssetStore(assetStore)
syncManager.setContentStore(contentStore)
syncManager.setConfig(config)

syncManager.start()
.then(() => {
	console.log('Contentstack sync started successfully!')
})
.catch(console.error)

Configuration

Here is the config table for the module:

Property Data Type Default value Description
pattern string /:uid/:filename Optional. The pattern to store asset is s3
region string us-east-1 Optional. The aws region
apiVersion string 2006-03-01 Optional. The aws api version
credentials object see config below Required. Specify access key and secret key
bucketParams object see config below Required. Specify bucket name and ACL
uploadParams object see config below Optional. Specify upload params
CORSConfiguration object see config below Optional. CORS configs
Policy object see config below Required. Specify policy

Detailed configs

By default, this module uses the following internal configuration.

{
  pattern: '/:uid/:filename',
  region: 'us-east-1',
  apiVersion: '2006-03-01',
  credentials: {                                             // Required 
    accessKeyId: '',
    secretAccessKey: ''
  },
  bucketParams: {
    ACL: 'public-read',
    Bucket: ''                                               // Required
  },
  uploadParams: {
    ACL: 'public-read'
  },
  CORSConfiguration: {
    CORSRules: [
      {
        AllowedHeaders: ['Authorization'],
        AllowedMethods: ['PUT', 'POST', 'GET', 'DELETE'],
        AllowedOrigins: ['*'],
        ExposeHeaders: [],
        MaxAgeSeconds: 3000
      }
    ]
  },
  Policy: {
    Version: '2012-10-17',
    Statement: [
      {
        Sid: 'AddPerm',
        Effect: 'Allow',
        Principal: '*',
        Action: ['s3:GetObject'],
        Resource: ['arn:aws:s3:::<bucket-name>/*']       // Required
      }
    ]
  },
}

Further Reading

Support and Feature requests

If you have any issues working with the library, please file an issue here at Github.

You can send us an e-mail at [email protected] if you have any support or feature requests. Our support team is available 24/7 on the intercom. You can always get in touch and give us an opportunity to serve you better!

License

This repository is published under the MIT license.